Commit da666c3702af437bdaf9a9de22fdab311903ecb3

Authored by JoenioCosta
1 parent 8fff632e

ActionItem312: person shouldnt create community to other person

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1740 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/views/profile/communities.rhtml
... ... @@ -13,7 +13,7 @@
13 13 <%= button :back, _('Go back'), { :controller => 'profile' },
14 14 :help => _('Back to the page where you come from.') %>
15 15 <%= button :add, _('Create a new community'),
16   - :controller => 'memberships', :action => 'new_community' if logged_in? %>
  16 + :controller => 'memberships', :action => 'new_community' if logged_in? && user == profile %>
17 17 <% end %>
18 18  
19 19 </div><!-- fim class="common-profile-list-block" -->
... ...
test/functional/profile_controller_test.rb
... ... @@ -145,4 +145,17 @@ class ProfileControllerTest &lt; Test::Unit::TestCase
145 145 assert_no_tag :tag => 'ul', :attributes => { :class => 'profile-info-data' }, :descendant => { :tag => 'a', :content => 'Control panel' }
146 146 end
147 147  
  148 + should 'show create community in own profile' do
  149 + login_as(@profile.identifier)
  150 + get :communities, :profile => @profile.identifier
  151 + assert_tag :tag => 'a', :child => { :tag => 'span', :content => 'Create a new community' }
  152 + end
  153 +
  154 + should 'not show create community on profile of other users' do
  155 + login_as(@profile.identifier)
  156 + person = create_user('person_1').person
  157 + get :communities, :profile => person.identifier
  158 + assert_no_tag :tag => 'a', :child => { :tag => 'span', :content => 'Create a new community' }
  159 + end
  160 +
148 161 end
... ...