First version of blocking feature. Allows both time-based (for map protection) and...
[rails.git] / test / functional / user_roles_controller_test.rb
1 require File.dirname(__FILE__) + '/../test_helper'
2
3 class UserRolesControllerTest < ActionController::TestCase
4   fixtures :users, :user_roles
5
6   test "grant" do
7     check_redirect(:grant, :public_user, "/403.html")
8     check_redirect(:grant, :moderator_user, "/403.html")
9     check_redirect(:grant, :administrator_user, {:controller => :user, :action => :view})
10   end
11
12   test "revoke" do
13     check_redirect(:revoke, :public_user, "/403.html")
14     check_redirect(:revoke, :moderator_user, "/403.html")
15     check_redirect(:revoke, :administrator_user, {:controller => :user, :action => :view})
16   end
17
18   def check_redirect(action, user, redirect)
19     UserRole::ALL_ROLES.each do |role|
20       u = users(user)
21       basic_authorization(u.email, "test")
22       
23       get(action, {:display_name => users(:second_public_user).display_name, :role => role}, {'user' => u.id})
24       assert_response :redirect
25       assert_redirected_to redirect
26     end
27   end
28 end