Commit 7d2227952e12ba539dd85bde1bdcff06b9f7577b
Committed by
Antonio Terceiro
1 parent
f1416f69
Exists in
master
and in
22 other branches
Removing button
* When listing members of a community/enterprise, button "remove" is not displayed on the line of the current user (ActionItem1454)
Showing
2 changed files
with
16 additions
and
2 deletions
Show diff stats
app/views/profile_members/_members_list.rhtml
| @@ -11,12 +11,12 @@ | @@ -11,12 +11,12 @@ | ||
| 11 | <td> | 11 | <td> |
| 12 | <div class="members-buttons-cell"> | 12 | <div class="members-buttons-cell"> |
| 13 | <%= button_without_text :edit, _('Edit'), :action => 'change_role', :id => m %> | 13 | <%= button_without_text :edit, _('Edit'), :action => 'change_role', :id => m %> |
| 14 | - <%= button_to_remote_without_text :remove, _('Remove'), | 14 | + <%= button_to_remote_without_text(:remove, _('Remove'), |
| 15 | :update => 'members-list', | 15 | :update => 'members-list', |
| 16 | :loading => '$("members-list").addClassName("loading")', | 16 | :loading => '$("members-list").addClassName("loading")', |
| 17 | :success => "$('tr-#{m.identifier}').show()", | 17 | :success => "$('tr-#{m.identifier}').show()", |
| 18 | :complete => '$("members-list").removeClassName("loading")', | 18 | :complete => '$("members-list").removeClassName("loading")', |
| 19 | - :url => {:action => 'unassociate', :id => m} %> | 19 | + :url => {:action => 'unassociate', :id => m}) if m != user %> |
| 20 | </div> | 20 | </div> |
| 21 | </td> | 21 | </td> |
| 22 | </tr> | 22 | </tr> |
test/functional/profile_members_controller_test.rb
| @@ -162,6 +162,20 @@ class ProfileMembersControllerTest < Test::Unit::TestCase | @@ -162,6 +162,20 @@ class ProfileMembersControllerTest < Test::Unit::TestCase | ||
| 162 | assert_no_tag :tag => 'a', :attributes => {:href => /add_members/} | 162 | assert_no_tag :tag => 'a', :attributes => {:href => /add_members/} |
| 163 | end | 163 | end |
| 164 | 164 | ||
| 165 | + should 'not display remove button if the member is the current user' do | ||
| 166 | + com = Community.create!(:name => 'Test Com', :identifier => 'test_com') | ||
| 167 | + admin = create_user_with_permission('admin-member', 'manage_memberships', com) | ||
| 168 | + member = fast_create(Person, :name => 'just-member') | ||
| 169 | + com.add_member(member) | ||
| 170 | + | ||
| 171 | + login_as(admin.identifier) | ||
| 172 | + | ||
| 173 | + get :index, :profile => com.identifier | ||
| 174 | + | ||
| 175 | + assert_tag :tag => 'td', :descendant => { :tag => 'a', :attributes => {:class => /icon-remove/, :onclick => /#{member.identifier}/} } | ||
| 176 | + assert_no_tag :tag => 'td', :descendant => { :tag => 'a', :attributes => {:class => /icon-remove/, :onclick => /#{admin.identifier}/} } | ||
| 177 | + end | ||
| 178 | + | ||
| 165 | should 'have a add_members page' do | 179 | should 'have a add_members page' do |
| 166 | ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') | 180 | ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') |
| 167 | u = create_user_with_permission('test_user', 'manage_memberships', ent) | 181 | u = create_user_with_permission('test_user', 'manage_memberships', ent) |