Commit 201327e1f319c42ded745ac216cb5b321df7636e
1 parent
8bcf8c4f
Exists in
master
and in
29 other branches
Created tests for the new controller and added images
Signed-off-by: Hebert Douglas <hebertdougl@gmail.com> Signed-off-by: André Bernardes <andrebsguedes@gmail.com>
Showing
4 changed files
with
85 additions
and
5 deletions
Show diff stats
2.07 KB
3.63 KB
public/stylesheets/application.css
... | ... | @@ -4685,6 +4685,12 @@ h1#agenda-title { |
4685 | 4685 | .controller-profile_editor a.control-panel-welcome-page { |
4686 | 4686 | background-image: url(../images/control-panel/welcome-page.png) |
4687 | 4687 | } |
4688 | +.controller-profile_editor a.control-panel-roles { | |
4689 | + background-image: url(../images/control-panel/role-management.png) | |
4690 | +} | |
4691 | +.controller-profile_editor .msie6 a.control-panel-roles { | |
4692 | + background-image: url(../images/control-panel/role-management.gif) | |
4693 | +} | |
4688 | 4694 | /* ==> public/stylesheets/controller_profile_members.css <== */ |
4689 | 4695 | .controller-profile_members .no-boxes { |
4690 | 4696 | margin: 30px | ... | ... |
test/functional/profile_roles_controller_test.rb
1 | -class ProfileRolesController < ActionController::TestCase | |
1 | +require_relative "../test_helper" | |
2 | +require 'profile_roles_controller' | |
3 | + | |
4 | +class ProfileRolesControllerTest < ActionController::TestCase | |
2 | 5 | |
3 | 6 | def setup |
4 | - @controller = RoleController.new | |
7 | + @controller = ProfileRolesController.new | |
5 | 8 | @request = ActionController::TestRequest.new |
6 | 9 | @response = ActionController::TestResponse.new |
7 | 10 | @role = Role.find(:first) |
8 | - login_as(:ze) | |
9 | 11 | end |
10 | 12 | |
11 | 13 | should 'create a custom role' do |
12 | - | |
14 | + community = fast_create(Community) | |
15 | + admin = create_user_with_permission('admin_user', 'manage_custom_roles', community) | |
16 | + login_as :admin_user | |
17 | + post :create, :profile => community.identifier, :role => {:name => "some_role", :permissions => ["edit_profile"] } | |
18 | + role = Role.last | |
13 | 19 | |
20 | + assert_equal "some_role" , role.name | |
21 | + assert_equal community.id, role.profile_id | |
14 | 22 | end |
15 | 23 | |
24 | + should 'not create a custom role without permission' do | |
25 | + community = fast_create(Community) | |
26 | + moderator = create_user_with_permission('profile_admin', 'edit_profile', community) | |
27 | + login_as :profile_admin | |
28 | + post :create, :profile => community.identifier, :role => {:name => "admin", :permissions => ["edit_profile"] } | |
29 | + | |
30 | + assert_response 403 | |
31 | + assert_template 'access_denied' | |
32 | + | |
33 | + role = Role.last | |
34 | + | |
35 | + assert_not_equal "admin" , role.name | |
36 | + end | |
37 | + | |
38 | + | |
16 | 39 | should 'delete a custom role not used' do |
40 | + community = fast_create(Community) | |
41 | + admin = create_user_with_permission('admin_user', 'manage_custom_roles', community) | |
42 | + login_as :admin_user | |
43 | + role = Role.create!({:name => 'delete_article', :key => 'profile_delete_article', :profile_id => community.id, :environment => Environment.default}, :without_protection => true) | |
44 | + post :remove , :profile => community.identifier, :id => role.id | |
17 | 45 | |
46 | + assert_response :redirect | |
47 | + assert_redirected_to :action => 'index' | |
48 | + | |
49 | + assert_not_includes Role.all, role | |
18 | 50 | end |
19 | 51 | |
20 | 52 | should 'delete a custom role being used' do |
53 | + community = fast_create(Community) | |
54 | + admin = create_user_with_permission('admin_user', 'manage_custom_roles', community) | |
55 | + login_as :admin_user | |
56 | + role = Role.create!({:name => 'delete_article', :key => 'profile_delete_article', :profile_id => community.id, :environment => Environment.default}, :without_protection => true) | |
57 | + admin.add_role(role, community) | |
58 | + moderator_role = Role.find_by_name("moderator") | |
59 | + | |
60 | + assert_not_includes community.members_by_role(moderator_role), admin | |
21 | 61 | |
62 | + post :remove , :profile => community.identifier, :id => role.id, :roles => [moderator_role.id] | |
63 | + | |
64 | + assert_response :redirect | |
65 | + assert_redirected_to :action => 'index' | |
66 | + | |
67 | + assert_not_includes Role.all, role | |
68 | + assert_includes community.members_by_role(moderator_role), admin | |
22 | 69 | end |
23 | 70 | |
24 | 71 | should 'assign a custom role to single user' do |
72 | + community = fast_create(Community) | |
73 | + admin = create_user_with_permission('admin_user', 'manage_custom_roles', community) | |
74 | + login_as :admin_user | |
75 | + role = Role.create!({:name => 'delete_article', :key => 'profile_delete_article', :profile_id => community.id, :environment => Environment.default}, :without_protection => true) | |
76 | + | |
77 | + assert_not_includes community.members_by_role(role), admin | |
78 | + | |
79 | + post :define, :profile => community.identifier, :id => role.id, :assign_role_by => "members", :person_id => admin.id | |
25 | 80 | |
81 | + assert_includes community.members_by_role(role), admin | |
26 | 82 | end |
27 | 83 | |
28 | 84 | should 'replace a role with a custom role' do |
85 | + community = fast_create(Community) | |
86 | + admin = create_user_with_permission('admin_user', 'manage_custom_roles', community) | |
87 | + moderator = create_user_with_permission('profile_admin', 'edit_profile', community) | |
88 | + login_as :admin_user | |
89 | + role = Role.create!({:name => 'delete_article', :key => 'profile_delete_article', :profile_id => community.id, :environment => Environment.default}, :without_protection => true) | |
90 | + moderator_role = Role.find_by_name("moderator") | |
91 | + admin.add_role(moderator_role, community) | |
92 | + | |
93 | + assert_not_includes community.members_by_role(role), admin | |
94 | + | |
95 | + assert_not_includes community.members_by_role(role), moderator | |
96 | + assert_not_includes community.members_by_role(moderator_role), moderator | |
97 | + | |
98 | + post :define, :profile => community.identifier, :id => role.id, :assign_role_by => "roles", :selected_role => moderator_role.id | |
99 | + | |
100 | + assert_not_includes community.members_by_role(moderator_role), admin | |
101 | + assert_includes community.members_by_role(role), admin | |
29 | 102 | |
103 | + assert_not_includes community.members_by_role(role), moderator | |
104 | + assert_not_includes community.members_by_role(moderator_role), moderator | |
30 | 105 | end |
31 | - role = Role.create!(:name => 'environment_role', :key => 'environment_role', :environment => Environment.default) | |
32 | 106 | end | ... | ... |