Commit 7d2227952e12ba539dd85bde1bdcff06b9f7577b
Committed by
Antonio Terceiro
1 parent
f1416f69
Exists in
master
and in
28 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 | 11 | <td> |
| 12 | 12 | <div class="members-buttons-cell"> |
| 13 | 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 | 15 | :update => 'members-list', |
| 16 | 16 | :loading => '$("members-list").addClassName("loading")', |
| 17 | 17 | :success => "$('tr-#{m.identifier}').show()", |
| 18 | 18 | :complete => '$("members-list").removeClassName("loading")', |
| 19 | - :url => {:action => 'unassociate', :id => m} %> | |
| 19 | + :url => {:action => 'unassociate', :id => m}) if m != user %> | |
| 20 | 20 | </div> |
| 21 | 21 | </td> |
| 22 | 22 | </tr> | ... | ... |
test/functional/profile_members_controller_test.rb
| ... | ... | @@ -162,6 +162,20 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
| 162 | 162 | assert_no_tag :tag => 'a', :attributes => {:href => /add_members/} |
| 163 | 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 | 179 | should 'have a add_members page' do |
| 166 | 180 | ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') |
| 167 | 181 | u = create_user_with_permission('test_user', 'manage_memberships', ent) | ... | ... |