Commit 04e25fca0e1d2233afa3383103becf2c2f7026ce
1 parent
c3308c85
Exists in
master
and in
29 other branches
Add option to disable enterprises list on user menu
(ActionItem2903)
Showing
5 changed files
with
37 additions
and
5 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -1134,12 +1134,12 @@ module ApplicationHelper |
1134 | 1134 | end |
1135 | 1135 | |
1136 | 1136 | def manage_enterprises |
1137 | - return unless user | |
1137 | + return unless user && user.environment.enabled?(:display_my_enterprises_on_user_menu) | |
1138 | 1138 | manage_link(user.enterprises, :enterprises) |
1139 | 1139 | end |
1140 | 1140 | |
1141 | 1141 | def manage_communities |
1142 | - return unless user && user.environment.enabled?('display_my_communities_on_user_menu') | |
1142 | + return unless user && user.environment.enabled?(:display_my_communities_on_user_menu) | |
1143 | 1143 | administered_communities = user.communities.more_popular.select {|c| c.admins.include? user} |
1144 | 1144 | manage_link(administered_communities, :communities) |
1145 | 1145 | end | ... | ... |
app/models/environment.rb
... | ... | @@ -128,7 +128,8 @@ class Environment < ActiveRecord::Base |
128 | 128 | 'skip_new_user_email_confirmation' => _('Skip e-mail confirmation for new users'), |
129 | 129 | 'send_welcome_email_to_new_users' => _('Send welcome e-mail to new users'), |
130 | 130 | 'allow_change_of_redirection_after_login' => _('Allow users to set the page to redirect after login'), |
131 | - 'display_my_communities_on_user_menu' => _('Display on menu the list of communities the user can manage') | |
131 | + 'display_my_communities_on_user_menu' => _('Display on menu the list of communities the user can manage'), | |
132 | + 'display_my_enterprises_on_user_menu' => _('Display on menu the list of enterprises the user can manage') | |
132 | 133 | } |
133 | 134 | end |
134 | 135 | ... | ... |
db/migrate/20131116165327_enable_enterprises_list_on_user_menu.rb
0 → 100644
... | ... | @@ -0,0 +1,14 @@ |
1 | +class EnableEnterprisesListOnUserMenu < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + # The enterprises were always listed on user menu. | |
4 | + # As now it is configured by admin, the running environments should not need to enable it | |
5 | + select_all("select id from environments").each do |environment| | |
6 | + env = Environment.find(environment['id']) | |
7 | + env.enable(:display_my_enterprises_on_user_menu) | |
8 | + end | |
9 | + end | |
10 | + | |
11 | + def self.down | |
12 | + #nothing to be done | |
13 | + end | |
14 | +end | ... | ... |
db/schema.rb
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | # |
10 | 10 | # It's strongly recommended to check this file into your version control system. |
11 | 11 | |
12 | -ActiveRecord::Schema.define(:version => 20131011164400) do | |
12 | +ActiveRecord::Schema.define(:version => 20131116165327) do | |
13 | 13 | |
14 | 14 | create_table "abuse_reports", :force => true do |t| |
15 | 15 | t.integer "reporter_id" | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -1613,8 +1613,12 @@ class ProfileControllerTest < ActionController::TestCase |
1613 | 1613 | end |
1614 | 1614 | end |
1615 | 1615 | |
1616 | - should 'build menu to the enterprise panel' do | |
1616 | + should 'build menu to the enterprise panel if enabled' do | |
1617 | 1617 | u = create_user('other_other_ze').person |
1618 | + | |
1619 | + Environment.any_instance.stubs(:enabled?).returns(false) | |
1620 | + Environment.any_instance.stubs(:enabled?).with('display_my_enterprises_on_user_menu').returns(true) | |
1621 | + | |
1618 | 1622 | Environment.any_instance.stubs(:required_person_fields).returns([]) |
1619 | 1623 | u.data = { :email => 'test@test.com', :fields_privacy => { } } |
1620 | 1624 | u.save! |
... | ... | @@ -1635,6 +1639,19 @@ class ProfileControllerTest < ActionController::TestCase |
1635 | 1639 | end |
1636 | 1640 | end |
1637 | 1641 | |
1642 | + should 'not build menu to the enterprise panel if not enabled' do | |
1643 | + user = create_user('enterprise_admin').person | |
1644 | + enterprise = fast_create(Enterprise) | |
1645 | + enterprise.add_admin(user) | |
1646 | + | |
1647 | + Environment.any_instance.stubs(:enabled?).returns(false) | |
1648 | + Environment.any_instance.stubs(:enabled?).with('display_my_enterprises_on_user_menu').returns(false) | |
1649 | + | |
1650 | + login_as(user.identifier) | |
1651 | + get :index | |
1652 | + assert_no_tag :tag => 'div', :attributes => {:id => 'manage-enterprises'} | |
1653 | + end | |
1654 | + | |
1638 | 1655 | should 'show enterprises field if enterprises are enabled on environment' do |
1639 | 1656 | person = fast_create(Person) |
1640 | 1657 | environment = person.environment | ... | ... |