1 require File.dirname(__FILE__) + '/../test_helper'
3 class UserRolesControllerTest < ActionController::TestCase
4 fixtures :users, :user_roles
7 check_forbidden(:grant, :public_user)
8 check_forbidden(:grant, :moderator_user)
9 check_success(:grant, :administrator_user)
13 check_forbidden(:revoke, :public_user)
14 check_forbidden(:revoke, :moderator_user)
15 check_success(:revoke, :administrator_user)
18 def check_forbidden(action, user)
19 UserRole::ALL_ROLES.each do |role|
21 basic_authorization(u.email, "test")
23 get(action, {:display_name => users(:second_public_user).display_name, :role => role}, {'user' => u.id})
24 assert_response :redirect
25 assert_redirected_to "/403.html"
29 def check_success(action, user)
30 UserRole::ALL_ROLES.each do |role|
32 basic_authorization(u.email, "test")
34 get(action, {:display_name => users(:second_public_user).display_name, :role => role}, {'user' => u.id})
35 assert_response :success