From 3e7e1a28d62645e078d045cc259c7166d31ed4fd Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Thu, 25 Oct 2012 19:16:10 -0200 Subject: [PATCH] Checking permission to display button to send_email --- app/views/profile_members/_index_buttons.rhtml | 4 +++- test/functional/profile_members_controller_test.rb | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/views/profile_members/_index_buttons.rhtml b/app/views/profile_members/_index_buttons.rhtml index e9c8fcb..1e12ad3 100644 --- a/app/views/profile_members/_index_buttons.rhtml +++ b/app/views/profile_members/_index_buttons.rhtml @@ -4,7 +4,9 @@ <% if profile.community? and user.has_permission?(:invite_members, profile) %> <%= button :search, _('Invite your friends to join %s') % profile.short_name, :controller => 'invite', :action => 'select_address_book' %> <% end %> - <%= button :send, _('Send e-mail to members'), :controller => 'profile', :action => 'send_mail' %> + <% if profile.community? and user.has_permission?(:send_mail_to_members, profile) %> + <%= button :send, _('Send e-mail to members'), :controller => 'profile', :action => 'send_mail' %> + <% end %> <% @plugins.dispatch(:manage_members_extra_buttons).each do |plugin_button| %> <%= button plugin_button[:icon], plugin_button[:title], plugin_button[:url] %> <% end %> diff --git a/test/functional/profile_members_controller_test.rb b/test/functional/profile_members_controller_test.rb index 7bcc28a..1317ae6 100644 --- a/test/functional/profile_members_controller_test.rb +++ b/test/functional/profile_members_controller_test.rb @@ -176,6 +176,25 @@ class ProfileMembersControllerTest < ActionController::TestCase assert_no_tag :tag => 'td', :descendant => { :tag => 'a', :attributes => {:class => /icon-remove/, :onclick => /#{admin.identifier}/} } end + should 'display send email to members that have the permission' do + community = Community.create!(:name => 'Test Com', :identifier => 'test_com') + person = create_user_with_permission('test_user', 'manage_memberships', community) + give_permission(person, 'send_mail_to_members', community) + login_as :test_user + + get :index, :profile => community.identifier + assert_tag :tag => 'a', :attributes => {:href => /send_mail/} + end + + should 'not display send email to members if doesn\'t have the permission' do + community = Community.create!(:name => 'Test Com', :identifier => 'test_com') + person = create_user_with_permission('test_user', 'manage_memberships', community) + login_as :test_user + + get :index, :profile => community.identifier + assert_no_tag :tag => 'a', :attributes => {:href => /send_mail/} + end + should 'have a add_members page' do ent = fast_create(Enterprise, :name => 'Test Ent', :identifier => 'test_ent') u = create_user_with_permission('test_user', 'manage_memberships', ent) -- libgit2 0.21.2