Commit 79d7401c7c9fd97dd7b096591f6de95554b26d7f
1 parent
306e49b8
Exists in
staging
and in
42 other branches
ActionItem384: added button 'Leave from community'
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1783 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
27 additions
and
2 deletions
Show diff stats
app/views/blocks/profile_info_actions/community.rhtml
| 1 | <ul> | 1 | <ul> |
| 2 | - <% if logged_in? && !profile.members.include?(user) %> | ||
| 3 | - <li><%= link_to content_tag('span', _('Join this community')), { :profile => user.identifier, :controller => 'memberships', :action => 'join', :id => profile.id }, :class => 'button with-text icon-add' %></li> | 2 | + <% if logged_in? %> |
| 3 | + <% if profile.members.include?(user) %> | ||
| 4 | + <li><%= link_to content_tag('span', _('Leave this community')), { :profile => user.identifier, :controller => 'memberships', :action => 'leave', :id => profile.id }, :class => 'button with-text icon-delete' %></li> | ||
| 5 | + <% else %> | ||
| 6 | + <li><%= link_to content_tag('span', _('Join this community')), { :profile => user.identifier, :controller => 'memberships', :action => 'join', :id => profile.id }, :class => 'button with-text icon-add' %></li> | ||
| 7 | + <% end %> | ||
| 4 | <% end %> | 8 | <% end %> |
| 5 | </ul> | 9 | </ul> |
test/functional/profile_controller_test.rb
| @@ -158,4 +158,25 @@ class ProfileControllerTest < Test::Unit::TestCase | @@ -158,4 +158,25 @@ class ProfileControllerTest < Test::Unit::TestCase | ||
| 158 | assert_no_tag :tag => 'a', :child => { :tag => 'span', :content => 'Create a new community' } | 158 | assert_no_tag :tag => 'a', :child => { :tag => 'span', :content => 'Create a new community' } |
| 159 | end | 159 | end |
| 160 | 160 | ||
| 161 | + should 'not show Leave This Community button for non-member users' do | ||
| 162 | + login_as(@profile.identifier) | ||
| 163 | + community = Community.create!(:name => 'my test community') | ||
| 164 | + get :index, :profile => community.identifier | ||
| 165 | + assert_no_tag :tag => 'a', :content => 'Leave this community' | ||
| 166 | + end | ||
| 167 | + | ||
| 168 | + should 'show Leave This Community button for member users' do | ||
| 169 | + login_as(@profile.identifier) | ||
| 170 | + community = Community.create!(:name => 'my test community') | ||
| 171 | + community.add_member(@profile) | ||
| 172 | + get :index, :profile => community.identifier | ||
| 173 | + assert_tag :tag => 'a', :content => 'Leave this community' | ||
| 174 | + end | ||
| 175 | + | ||
| 176 | + should 'not show Leave This Community button for non-registered users' do | ||
| 177 | + community = Community.create!(:name => 'my test community') | ||
| 178 | + get :index, :profile => community.identifier | ||
| 179 | + assert_no_tag :tag => 'a', :content => 'Leave this community' | ||
| 180 | + end | ||
| 181 | + | ||
| 161 | end | 182 | end |