]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/oauth2_authorizations_controller_test.rb
Convert social share helper library into a real helper
[rails.git] / test / controllers / oauth2_authorizations_controller_test.rb
index 43fbe4df495a3db150889ccdd0215e884c1bc865..012bfd7f470877ebd340c2cdec4ec1cb5d4eb206 100644 (file)
@@ -29,7 +29,6 @@ class Oauth2AuthorizationsControllerTest < ActionDispatch::IntegrationTest
                                  :redirect_uri => application.redirect_uri,
                                  :response_type => "code",
                                  :scope => "write_api")
                                  :redirect_uri => application.redirect_uri,
                                  :response_type => "code",
                                  :scope => "write_api")
-    assert_response :redirect
     assert_redirected_to login_path(:referer => oauth_authorization_path(:client_id => application.uid,
                                                                          :redirect_uri => application.redirect_uri,
                                                                          :response_type => "code",
     assert_redirected_to login_path(:referer => oauth_authorization_path(:client_id => application.uid,
                                                                          :redirect_uri => application.redirect_uri,
                                                                          :response_type => "code",
@@ -52,7 +51,6 @@ class Oauth2AuthorizationsControllerTest < ActionDispatch::IntegrationTest
                                  :redirect_uri => application.redirect_uri,
                                  :response_type => "code",
                                  :scope => "write_api")
                                  :redirect_uri => application.redirect_uri,
                                  :response_type => "code",
                                  :scope => "write_api")
-    assert_response :redirect
     assert_redirected_to login_path(:referer => oauth_authorization_path(:client_id => application.uid,
                                                                          :redirect_uri => application.redirect_uri,
                                                                          :response_type => "code",
     assert_redirected_to login_path(:referer => oauth_authorization_path(:client_id => application.uid,
                                                                          :redirect_uri => application.redirect_uri,
                                                                          :response_type => "code",
@@ -104,6 +102,20 @@ class Oauth2AuthorizationsControllerTest < ActionDispatch::IntegrationTest
     assert_select "p", "The requested scope is invalid, unknown, or malformed."
   end
 
     assert_select "p", "The requested scope is invalid, unknown, or malformed."
   end
 
+  def test_new_db_readonly
+    application = create(:oauth_application, :scopes => "write_api")
+
+    session_for(create(:user))
+
+    with_settings(:status => "database_readonly") do
+      get oauth_authorization_path(:client_id => application.uid,
+                                   :redirect_uri => application.redirect_uri,
+                                   :response_type => "code",
+                                   :scope => "write_api")
+      assert_redirected_to offline_path
+    end
+  end
+
   def test_create
     application = create(:oauth_application, :scopes => "write_api")
 
   def test_create
     application = create(:oauth_application, :scopes => "write_api")
 
@@ -119,7 +131,6 @@ class Oauth2AuthorizationsControllerTest < ActionDispatch::IntegrationTest
                                   :redirect_uri => application.redirect_uri,
                                   :response_type => "code",
                                   :scope => "write_api")
                                   :redirect_uri => application.redirect_uri,
                                   :response_type => "code",
                                   :scope => "write_api")
-    assert_response :redirect
     assert_redirected_to(/^#{Regexp.escape(application.redirect_uri)}\?code=/)
   end
 
     assert_redirected_to(/^#{Regexp.escape(application.redirect_uri)}\?code=/)
   end
 
@@ -160,7 +171,6 @@ class Oauth2AuthorizationsControllerTest < ActionDispatch::IntegrationTest
                                     :redirect_uri => application.redirect_uri,
                                     :response_type => "code",
                                     :scope => "write_api")
                                     :redirect_uri => application.redirect_uri,
                                     :response_type => "code",
                                     :scope => "write_api")
-    assert_response :redirect
     assert_redirected_to(/^#{Regexp.escape(application.redirect_uri)}\?error=access_denied/)
   end
 
     assert_redirected_to(/^#{Regexp.escape(application.redirect_uri)}\?error=access_denied/)
   end