3 class Oauth2AuthorizedApplicationsControllerTest < ActionDispatch::IntegrationTest
 
   5   # test all routes which lead to this controller
 
   8       { :path => "/oauth2/authorized_applications", :method => :get },
 
   9       { :controller => "oauth2_authorized_applications", :action => "index" }
 
  12       { :path => "/oauth2/authorized_applications/1", :method => :delete },
 
  13       { :controller => "oauth2_authorized_applications", :action => "destroy", :id => "1" }
 
  19     application1 = create(:oauth_application)
 
  20     create(:oauth_access_grant, :user => user, :application => application1)
 
  21     create(:oauth_access_token, :user => user, :application => application1)
 
  22     application2 = create(:oauth_application)
 
  23     create(:oauth_access_grant, :user => user, :application => application2)
 
  24     create(:oauth_access_token, :user => user, :application => application2)
 
  25     create(:oauth_application)
 
  27     get oauth_authorized_applications_path
 
  28     assert_redirected_to login_path(:referer => oauth_authorized_applications_path)
 
  32     get oauth_authorized_applications_path
 
  33     assert_response :success
 
  34     assert_template "oauth2_authorized_applications/index"
 
  35     assert_select "tbody tr", 2
 
  40     application1 = create(:oauth_application, :scopes => %w[read_prefs write_prefs write_diary read_gpx write_gpx])
 
  41     create(:oauth_access_grant, :user => user, :application => application1, :scopes => %w[read_prefs write_prefs])
 
  42     create(:oauth_access_token, :user => user, :application => application1, :scopes => %w[read_prefs write_prefs])
 
  43     create(:oauth_access_grant, :user => user, :application => application1, :scopes => %w[read_prefs write_diary])
 
  44     create(:oauth_access_token, :user => user, :application => application1, :scopes => %w[read_prefs write_diary])
 
  46     get oauth_authorized_applications_path
 
  47     assert_redirected_to login_path(:referer => oauth_authorized_applications_path)
 
  51     get oauth_authorized_applications_path
 
  52     assert_response :success
 
  53     assert_template "oauth2_authorized_applications/index"
 
  54     assert_select "tbody tr", 1
 
  55     assert_select "tbody tr td ul" do
 
  56       assert_select "li", :count => 3
 
  57       assert_select "li", :text => "Read user preferences"
 
  58       assert_select "li", :text => "Modify user preferences"
 
  59       assert_select "li", :text => "Create diary entries and comments"
 
  65     application1 = create(:oauth_application)
 
  66     create(:oauth_access_grant, :user => user, :application => application1)
 
  67     create(:oauth_access_token, :user => user, :application => application1)
 
  68     application2 = create(:oauth_application)
 
  69     create(:oauth_access_grant, :user => user, :application => application2)
 
  70     create(:oauth_access_token, :user => user, :application => application2)
 
  71     create(:oauth_application)
 
  73     delete oauth_authorized_application_path(:id => application1.id)
 
  74     assert_response :forbidden
 
  78     delete oauth_authorized_application_path(:id => application1.id)
 
  79     assert_redirected_to oauth_authorized_applications_path
 
  81     get oauth_authorized_applications_path
 
  82     assert_response :success
 
  83     assert_template "oauth2_authorized_applications/index"
 
  84     assert_select "tbody tr", 1