From da666c3702af437bdaf9a9de22fdab311903ecb3 Mon Sep 17 00:00:00 2001 From: JoenioCosta Date: Tue, 29 Apr 2008 05:40:23 +0000 Subject: [PATCH] ActionItem312: person shouldnt create community to other person --- app/views/profile/communities.rhtml | 2 +- test/functional/profile_controller_test.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/views/profile/communities.rhtml b/app/views/profile/communities.rhtml index dc4588f..22b974b 100644 --- a/app/views/profile/communities.rhtml +++ b/app/views/profile/communities.rhtml @@ -13,7 +13,7 @@ <%= button :back, _('Go back'), { :controller => 'profile' }, :help => _('Back to the page where you come from.') %> <%= button :add, _('Create a new community'), - :controller => 'memberships', :action => 'new_community' if logged_in? %> + :controller => 'memberships', :action => 'new_community' if logged_in? && user == profile %> <% end %> diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb index fd42888..4723a4b 100644 --- a/test/functional/profile_controller_test.rb +++ b/test/functional/profile_controller_test.rb @@ -145,4 +145,17 @@ class ProfileControllerTest < Test::Unit::TestCase assert_no_tag :tag => 'ul', :attributes => { :class => 'profile-info-data' }, :descendant => { :tag => 'a', :content => 'Control panel' } end + should 'show create community in own profile' do + login_as(@profile.identifier) + get :communities, :profile => @profile.identifier + assert_tag :tag => 'a', :child => { :tag => 'span', :content => 'Create a new community' } + end + + should 'not show create community on profile of other users' do + login_as(@profile.identifier) + person = create_user('person_1').person + get :communities, :profile => person.identifier + assert_no_tag :tag => 'a', :child => { :tag => 'span', :content => 'Create a new community' } + end + end -- libgit2 0.21.2