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, :resource_owner_id => user.id, :application => application1)
21 create(:oauth_access_token, :resource_owner_id => user.id, :application => application1)
22 application2 = create(:oauth_application)
23 create(:oauth_access_grant, :resource_owner_id => user.id, :application => application2)
24 create(:oauth_access_token, :resource_owner_id => user.id, :application => application2)
25 create(:oauth_application)
27 get oauth_authorized_applications_path
28 assert_response :redirect
29 assert_redirected_to login_path(:referer => oauth_authorized_applications_path)
33 get oauth_authorized_applications_path
34 assert_response :success
35 assert_template "oauth2_authorized_applications/index"
36 assert_select "tbody tr", 2
41 application1 = create(:oauth_application, :scopes => %w[read_prefs write_prefs write_diary read_gpx write_gpx])
42 create(:oauth_access_grant, :resource_owner_id => user.id, :application => application1, :scopes => %w[read_prefs write_prefs])
43 create(:oauth_access_token, :resource_owner_id => user.id, :application => application1, :scopes => %w[read_prefs write_prefs])
44 create(:oauth_access_grant, :resource_owner_id => user.id, :application => application1, :scopes => %w[read_prefs write_diary])
45 create(:oauth_access_token, :resource_owner_id => user.id, :application => application1, :scopes => %w[read_prefs write_diary])
47 get oauth_authorized_applications_path
48 assert_response :redirect
49 assert_redirected_to login_path(:referer => oauth_authorized_applications_path)
53 get oauth_authorized_applications_path
54 assert_response :success
55 assert_template "oauth2_authorized_applications/index"
56 assert_select "tbody tr", 1
57 assert_select "tbody tr td ul" do
58 assert_select "li", :count => 3
59 assert_select "li", :text => "Read user preferences"
60 assert_select "li", :text => "Modify user preferences"
61 assert_select "li", :text => "Create diary entries, comments and make friends"
67 application1 = create(:oauth_application)
68 create(:oauth_access_grant, :resource_owner_id => user.id, :application => application1)
69 create(:oauth_access_token, :resource_owner_id => user.id, :application => application1)
70 application2 = create(:oauth_application)
71 create(:oauth_access_grant, :resource_owner_id => user.id, :application => application2)
72 create(:oauth_access_token, :resource_owner_id => user.id, :application => application2)
73 create(:oauth_application)
75 delete oauth_authorized_application_path(:id => application1.id)
76 assert_response :forbidden
80 delete oauth_authorized_application_path(:id => application1.id)
81 assert_response :redirect
82 assert_redirected_to oauth_authorized_applications_path
84 get oauth_authorized_applications_path
85 assert_response :success
86 assert_template "oauth2_authorized_applications/index"
87 assert_select "tbody tr", 1