]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/oauth_clients_controller_test.rb
Test links to containing relations from element pages
[rails.git] / test / controllers / oauth_clients_controller_test.rb
index b610cb0b782fba5163b1c845e0d6827b5d08b696..e448e09541117b2624e23ca45739c8bd5495c453 100644 (file)
@@ -40,7 +40,6 @@ class OauthClientsControllerTest < ActionDispatch::IntegrationTest
     create_list(:access_token, 2, :user => user)
 
     get oauth_clients_path(:display_name => user.display_name)
-    assert_response :redirect
     assert_redirected_to login_path(:referer => oauth_clients_path(:display_name => user.display_name))
 
     session_for(user)
@@ -48,14 +47,13 @@ class OauthClientsControllerTest < ActionDispatch::IntegrationTest
     get oauth_clients_path(:display_name => user.display_name)
     assert_response :success
     assert_template "index"
-    assert_select "div.client_application", 2
+    assert_select "li.client_application", 2
   end
 
   def test_new
     user = create(:user)
 
     get new_oauth_client_path(:display_name => user.display_name)
-    assert_response :redirect
     assert_redirected_to login_path(:referer => new_oauth_client_path(:display_name => user.display_name))
 
     session_for(user)
@@ -74,6 +72,20 @@ class OauthClientsControllerTest < ActionDispatch::IntegrationTest
     end
   end
 
+  def test_new_disabled
+    user = create(:user)
+
+    with_settings(:oauth_10_registration => false) do
+      get new_oauth_client_path(:display_name => user.display_name)
+      assert_redirected_to login_path(:referer => new_oauth_client_path(:display_name => user.display_name))
+
+      session_for(user)
+
+      get new_oauth_client_path(:display_name => user.display_name)
+      assert_redirected_to oauth_clients_path(:display_name => user.display_name)
+    end
+  end
+
   def test_create
     user = create(:user)
 
@@ -96,7 +108,6 @@ class OauthClientsControllerTest < ActionDispatch::IntegrationTest
                               :client_application => { :name => "Test Application",
                                                        :url => "http://test.example.com/" })
     end
-    assert_response :redirect
     assert_redirected_to oauth_client_path(:id => ClientApplication.find_by(:name => "Test Application").id)
   end
 
@@ -106,7 +117,6 @@ class OauthClientsControllerTest < ActionDispatch::IntegrationTest
     other_client = create(:client_application)
 
     get oauth_client_path(:display_name => user.display_name, :id => client)
-    assert_response :redirect
     assert_redirected_to login_path(:referer => oauth_client_path(:display_name => user.display_name, :id => client.id))
 
     session_for(user)
@@ -126,7 +136,6 @@ class OauthClientsControllerTest < ActionDispatch::IntegrationTest
     other_client = create(:client_application)
 
     get edit_oauth_client_path(:display_name => user.display_name, :id => client)
-    assert_response :redirect
     assert_redirected_to login_path(:referer => edit_oauth_client_path(:display_name => user.display_name, :id => client.id))
 
     session_for(user)
@@ -170,7 +179,6 @@ class OauthClientsControllerTest < ActionDispatch::IntegrationTest
 
     put oauth_client_path(:display_name => user.display_name, :id => client,
                           :client_application => { :name => "New Name", :url => "http://new.example.com/url" })
-    assert_response :redirect
     assert_redirected_to oauth_client_path(:id => client.id)
   end
 
@@ -195,7 +203,6 @@ class OauthClientsControllerTest < ActionDispatch::IntegrationTest
     assert_difference "ClientApplication.count", -1 do
       delete oauth_client_path(:display_name => user.display_name, :id => client)
     end
-    assert_response :redirect
     assert_redirected_to oauth_clients_path(:display_name => user.display_name)
   end
 end