X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/6c6e8883f703efe8e05d893a94c169ac90733d42..e28a8fd9920838eb0541af0cc1e251b1249309b2:/test/controllers/oauth2_applications_controller_test.rb?ds=inline diff --git a/test/controllers/oauth2_applications_controller_test.rb b/test/controllers/oauth2_applications_controller_test.rb index 338144a95..1b6eaabfe 100644 --- a/test/controllers/oauth2_applications_controller_test.rb +++ b/test/controllers/oauth2_applications_controller_test.rb @@ -51,7 +51,7 @@ class Oauth2ApplicationsControllerTest < ActionDispatch::IntegrationTest get oauth_applications_path assert_response :success assert_template "oauth2_applications/index" - assert_select "tr", 2 + assert_select "tbody tr", 2 end def test_new @@ -115,6 +115,32 @@ class Oauth2ApplicationsControllerTest < ActionDispatch::IntegrationTest assert_redirected_to oauth_application_path(:id => Doorkeeper::Application.find_by(:name => "Test Application").id) end + def test_create_privileged + session_for(create(:user)) + + assert_difference "Doorkeeper::Application.count", 0 do + post oauth_applications_path(:oauth2_application => { + :name => "Test Application", + :redirect_uri => "https://test.example.com/", + :scopes => ["read_email"] + }) + end + assert_response :success + assert_template "oauth2_applications/new" + + session_for(create(:administrator_user)) + + assert_difference "Doorkeeper::Application.count", 1 do + post oauth_applications_path(:oauth2_application => { + :name => "Test Application", + :redirect_uri => "https://test.example.com/", + :scopes => ["read_email"] + }) + end + assert_response :redirect + assert_redirected_to oauth_application_path(:id => Doorkeeper::Application.find_by(:name => "Test Application").id) + end + def test_show user = create(:user) client = create(:oauth_application, :owner => user)