]> git.openstreetmap.org Git - rails.git/blobdiff - test/functional/user_roles_controller_test.rb
Allow POST requests to the home page so OpenSearch works
[rails.git] / test / functional / user_roles_controller_test.rb
index c2de53934827328039eada4b94f2f3aaa1cf9277..1e2d29b450eca82019e2ff225ac0f3357f8339fb 100644 (file)
@@ -1,28 +1,24 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
 class UserRolesControllerTest < ActionController::TestCase
 require File.dirname(__FILE__) + '/../test_helper'
 
 class UserRolesControllerTest < ActionController::TestCase
-  fixtures :users, :user_roles
-
-  test "grant" do
-    check_redirect(:grant, :public_user, "/403.html")
-    check_redirect(:grant, :moderator_user, "/403.html")
-    check_redirect(:grant, :administrator_user, {:controller => :user, :action => :view})
-  end
-
-  test "revoke" do
-    check_redirect(:revoke, :public_user, "/403.html")
-    check_redirect(:revoke, :moderator_user, "/403.html")
-    check_redirect(:revoke, :administrator_user, {:controller => :user, :action => :view})
-  end
-
-  def check_redirect(action, user, redirect)
-    UserRole::ALL_ROLES.each do |role|
-      u = users(user)
-      basic_authorization(u.email, "test")
-      
-      get(action, {:display_name => users(:second_public_user).display_name, :role => role}, {'user' => u.id})
-      assert_response :redirect
-      assert_redirected_to redirect
-    end
+  ##
+  # test all routes which lead to this controller
+  def test_routes
+    assert_routing(
+      { :path => "/user/username/role/rolename/grant", :method => :get },
+      { :controller => "user_roles", :action => "grant", :display_name => "username", :role => "rolename" }
+    )
+    assert_routing(
+      { :path => "/user/username/role/rolename/grant", :method => :post },
+      { :controller => "user_roles", :action => "grant", :display_name => "username", :role => "rolename" }
+    )
+    assert_routing(
+      { :path => "/user/username/role/rolename/revoke", :method => :get },
+      { :controller => "user_roles", :action => "revoke", :display_name => "username", :role => "rolename" }
+    )
+    assert_routing(
+      { :path => "/user/username/role/rolename/revoke", :method => :post },
+      { :controller => "user_roles", :action => "revoke", :display_name => "username", :role => "rolename" }
+    )
   end
 end
   end
 end