Commit b146eb60a4a51faf0834400dd07534493da0e16e
1 parent
0af76ab3
Exists in
master
and in
29 other branches
ActionItem226: not show 'Join this community' to members
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1615 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
23 additions
and
1 deletions
Show diff stats
app/views/blocks/profile_info_actions/community.rhtml
1 | <ul> | 1 | <ul> |
2 | - <% if logged_in? %> | 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> | 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> |
4 | <% end %> | 4 | <% end %> |
5 | </ul> | 5 | </ul> |
test/functional/profile_controller_test.rb
@@ -46,4 +46,26 @@ class ProfileControllerTest < Test::Unit::TestCase | @@ -46,4 +46,26 @@ class ProfileControllerTest < Test::Unit::TestCase | ||
46 | assert_template 'members' | 46 | assert_template 'members' |
47 | assert_kind_of Array, assigns(:members) | 47 | assert_kind_of Array, assigns(:members) |
48 | end | 48 | end |
49 | + | ||
50 | + should 'show Join This Community button for non-member users' do | ||
51 | + login_as(@profile.identifier) | ||
52 | + community = Community.create!(:name => 'my test community') | ||
53 | + get :index, :profile => community.identifier | ||
54 | + assert_tag :tag => 'a', :content => 'Join this community' | ||
55 | + end | ||
56 | + | ||
57 | + should 'not show Join This Community button for member users' do | ||
58 | + login_as(@profile.identifier) | ||
59 | + community = Community.create!(:name => 'my test community') | ||
60 | + community.add_member(@profile) | ||
61 | + get :index, :profile => community.identifier | ||
62 | + assert_no_tag :tag => 'a', :content => 'Join this community' | ||
63 | + end | ||
64 | + | ||
65 | + should 'not show Join This Community button for non-registered users' do | ||
66 | + community = Community.create!(:name => 'my test community') | ||
67 | + get :index, :profile => community.identifier | ||
68 | + assert_no_tag :tag => 'a', :content => 'Join this community' | ||
69 | + end | ||
70 | + | ||
49 | end | 71 | end |