Commit 3e7e1a28d62645e078d045cc259c7166d31ed4fd
1 parent
76d1fba0
Exists in
master
and in
29 other branches
Checking permission to display button to send_email
(ActionItem2388)
Showing
2 changed files
with
22 additions
and
1 deletions
Show diff stats
app/views/profile_members/_index_buttons.rhtml
... | ... | @@ -4,7 +4,9 @@ |
4 | 4 | <% if profile.community? and user.has_permission?(:invite_members, profile) %> |
5 | 5 | <%= button :search, _('Invite your friends to join %s') % profile.short_name, :controller => 'invite', :action => 'select_address_book' %> |
6 | 6 | <% end %> |
7 | - <%= button :send, _('Send e-mail to members'), :controller => 'profile', :action => 'send_mail' %> | |
7 | + <% if profile.community? and user.has_permission?(:send_mail_to_members, profile) %> | |
8 | + <%= button :send, _('Send e-mail to members'), :controller => 'profile', :action => 'send_mail' %> | |
9 | + <% end %> | |
8 | 10 | <% @plugins.dispatch(:manage_members_extra_buttons).each do |plugin_button| %> |
9 | 11 | <%= button plugin_button[:icon], plugin_button[:title], plugin_button[:url] %> |
10 | 12 | <% end %> | ... | ... |
test/functional/profile_members_controller_test.rb
... | ... | @@ -176,6 +176,25 @@ class ProfileMembersControllerTest < ActionController::TestCase |
176 | 176 | assert_no_tag :tag => 'td', :descendant => { :tag => 'a', :attributes => {:class => /icon-remove/, :onclick => /#{admin.identifier}/} } |
177 | 177 | end |
178 | 178 | |
179 | + should 'display send email to members that have the permission' do | |
180 | + community = Community.create!(:name => 'Test Com', :identifier => 'test_com') | |
181 | + person = create_user_with_permission('test_user', 'manage_memberships', community) | |
182 | + give_permission(person, 'send_mail_to_members', community) | |
183 | + login_as :test_user | |
184 | + | |
185 | + get :index, :profile => community.identifier | |
186 | + assert_tag :tag => 'a', :attributes => {:href => /send_mail/} | |
187 | + end | |
188 | + | |
189 | + should 'not display send email to members if doesn\'t have the permission' do | |
190 | + community = Community.create!(:name => 'Test Com', :identifier => 'test_com') | |
191 | + person = create_user_with_permission('test_user', 'manage_memberships', community) | |
192 | + login_as :test_user | |
193 | + | |
194 | + get :index, :profile => community.identifier | |
195 | + assert_no_tag :tag => 'a', :attributes => {:href => /send_mail/} | |
196 | + end | |
197 | + | |
179 | 198 | should 'have a add_members page' do |
180 | 199 | ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent') |
181 | 200 | u = create_user_with_permission('test_user', 'manage_memberships', ent) | ... | ... |