diff --git a/app/views/profile_members/_members_list.rhtml b/app/views/profile_members/_members_list.rhtml index 06baca8..0b08a36 100644 --- a/app/views/profile_members/_members_list.rhtml +++ b/app/views/profile_members/_members_list.rhtml @@ -11,12 +11,12 @@
<%= button_without_text :edit, _('Edit'), :action => 'change_role', :id => m %> - <%= button_to_remote_without_text :remove, _('Remove'), + <%= button_to_remote_without_text(:remove, _('Remove'), :update => 'members-list', :loading => '$("members-list").addClassName("loading")', :success => "$('tr-#{m.identifier}').show()", :complete => '$("members-list").removeClassName("loading")', - :url => {:action => 'unassociate', :id => m} %> + :url => {:action => 'unassociate', :id => m}) if m != user %>
diff --git a/test/functional/profile_members_controller_test.rb b/test/functional/profile_members_controller_test.rb index df1452e..3efcd44 100644 --- a/test/functional/profile_members_controller_test.rb +++ b/test/functional/profile_members_controller_test.rb @@ -162,6 +162,20 @@ class ProfileMembersControllerTest < Test::Unit::TestCase assert_no_tag :tag => 'a', :attributes => {:href => /add_members/} end + should 'not display remove button if the member is the current user' do + com = Community.create!(:name => 'Test Com', :identifier => 'test_com') + admin = create_user_with_permission('admin-member', 'manage_memberships', com) + member = fast_create(Person, :name => 'just-member') + com.add_member(member) + + login_as(admin.identifier) + + get :index, :profile => com.identifier + + assert_tag :tag => 'td', :descendant => { :tag => 'a', :attributes => {:class => /icon-remove/, :onclick => /#{member.identifier}/} } + assert_no_tag :tag => 'td', :descendant => { :tag => 'a', :attributes => {:class => /icon-remove/, :onclick => /#{admin.identifier}/} } + end + should 'have a add_members page' do ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') u = create_user_with_permission('test_user', 'manage_memberships', ent) -- libgit2 0.21.2