diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c7f95da..25eee2b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1139,7 +1139,7 @@ module ApplicationHelper end def manage_communities - return unless user && !user.environment.enabled?('disable_my_communities_menu') + return unless user && user.environment.enabled?('display_my_communities_on_user_menu') administered_communities = user.communities.more_popular.select {|c| c.admins.include? user} manage_link(administered_communities, :communities) end diff --git a/app/models/environment.rb b/app/models/environment.rb index 49ee5a9..3a42c41 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -97,7 +97,6 @@ class Environment < ActiveRecord::Base 'disable_asset_events' => _('Disable search for events'), 'disable_categories' => _('Disable categories'), 'disable_header_and_footer' => _('Disable header/footer editing by users'), - 'disable_my_communities_menu' => _('Disable My Communities menu'), 'disable_gender_icon' => _('Disable gender icon'), 'disable_categories_menu' => _('Disable the categories menu'), 'disable_select_city_for_contact' => _('Disable state/city select for contact form'), @@ -128,7 +127,8 @@ class Environment < ActiveRecord::Base 'captcha_for_logged_users' => _('Ask captcha when a logged user comments too'), 'skip_new_user_email_confirmation' => _('Skip e-mail confirmation for new users'), 'send_welcome_email_to_new_users' => _('Send welcome e-mail to new users'), - 'allow_change_of_redirection_after_login' => _('Allow users to set the page to redirect after login') + 'allow_change_of_redirection_after_login' => _('Allow users to set the page to redirect after login'), + 'display_my_communities_on_user_menu' => _('Display on menu the list of communities the user can manage') } end diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb index 4403ce5..f4312c4 100644 --- a/test/functional/profile_controller_test.rb +++ b/test/functional/profile_controller_test.rb @@ -1549,16 +1549,45 @@ class ProfileControllerTest < ActionController::TestCase assert_tag :tag => 'td', :content => 'e-Mail:' end - should 'build menu to the community panel if enabled' do + should 'not display list of communities to manage on menu by default' do + user = create_user('community_admin').person + community = fast_create(Community) + community.add_admin(user) + + login_as(user.identifier) + get :index + assert_no_tag :tag => 'div', :attributes => {:id => 'manage-communities'} + end + + should 'display list of communities to manage on menu if enabled' do + user = create_user('community_admin').person + env = user.environment + community = fast_create(Community) + community.add_admin(user) + + Environment.any_instance.stubs(:enabled?).returns(false) + Environment.any_instance.stubs(:enabled?).with('display_my_communities_on_user_menu').returns(true) + + login_as(user.identifier) + get :index + assert_tag :tag => 'div', :attributes => {:id => 'manage-communities'} + + end + + should 'build menu to the community panel of communities the user can manage if enabled' do u = create_user('other_other_ze').person u2 = create_user('guy_that_will_be_admin_of_all').person # because the first member of each community is an admin + + Environment.any_instance.stubs(:enabled?).returns(false) + Environment.any_instance.stubs(:enabled?).with('display_my_communities_on_user_menu').returns(true) + Environment.any_instance.stubs(:required_person_fields).returns([]) u.data = { :email => 'test@test.com', :fields_privacy => { } } u.save! - c1 = Community.create!(:name => 'community_1') - c2 = Community.create!(:name => 'community_2') - c3 = Community.create!(:name => 'community_3') - c4 = Community.create!(:name => 'community_4') + c1 = fast_create(Community, :name => 'community_1') + c2 = fast_create(Community, :name => 'community_2') + c3 = fast_create(Community, :name => 'community_3') + c4 = fast_create(Community, :name => 'community_4') c1.add_admin(u2) c2.add_admin(u2) @@ -1582,12 +1611,6 @@ class ProfileControllerTest < ActionController::TestCase assert_no_match /community_3/, links.to_s assert_no_match /community_4/, links.to_s end - - Environment.any_instance.stubs(:enabled?).returns(false) - Environment.any_instance.stubs(:enabled?).with('disable_my_communities_menu').returns(true) - - get :index - assert_no_tag :tag => 'div', :attributes => {:id => 'manage-communities'} end should 'build menu to the enterprise panel' do -- libgit2 0.21.2