Commit 0fbd1b38cff72dcc6abc155bd73aa1e32fdc9ae5
Exists in
master
and in
29 other branches
Merge remote branch 'larissa/makes-my-community-opicional'
Showing
3 changed files
with
18 additions
and
11 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -1134,12 +1134,12 @@ module ApplicationHelper | @@ -1134,12 +1134,12 @@ module ApplicationHelper | ||
1134 | end | 1134 | end |
1135 | 1135 | ||
1136 | def manage_enterprises | 1136 | def manage_enterprises |
1137 | - return if not user | 1137 | + return unless user |
1138 | manage_link(user.enterprises, :enterprises) | 1138 | manage_link(user.enterprises, :enterprises) |
1139 | end | 1139 | end |
1140 | 1140 | ||
1141 | def manage_communities | 1141 | def manage_communities |
1142 | - return if not user | 1142 | + return unless user && !user.environment.enabled?('disable_my_communities_menu') |
1143 | administered_communities = user.communities.more_popular.select {|c| c.admins.include? user} | 1143 | administered_communities = user.communities.more_popular.select {|c| c.admins.include? user} |
1144 | manage_link(administered_communities, :communities) | 1144 | manage_link(administered_communities, :communities) |
1145 | end | 1145 | end |
app/models/environment.rb
@@ -97,6 +97,7 @@ class Environment < ActiveRecord::Base | @@ -97,6 +97,7 @@ class Environment < ActiveRecord::Base | ||
97 | 'disable_asset_events' => _('Disable search for events'), | 97 | 'disable_asset_events' => _('Disable search for events'), |
98 | 'disable_categories' => _('Disable categories'), | 98 | 'disable_categories' => _('Disable categories'), |
99 | 'disable_header_and_footer' => _('Disable header/footer editing by users'), | 99 | 'disable_header_and_footer' => _('Disable header/footer editing by users'), |
100 | + 'disable_my_communities_menu' => _('Disable My Communities menu'), | ||
100 | 'disable_gender_icon' => _('Disable gender icon'), | 101 | 'disable_gender_icon' => _('Disable gender icon'), |
101 | 'disable_categories_menu' => _('Disable the categories menu'), | 102 | 'disable_categories_menu' => _('Disable the categories menu'), |
102 | 'disable_select_city_for_contact' => _('Disable state/city select for contact form'), | 103 | 'disable_select_city_for_contact' => _('Disable state/city select for contact form'), |
test/functional/profile_controller_test.rb
@@ -17,11 +17,11 @@ class ProfileControllerTest < ActionController::TestCase | @@ -17,11 +17,11 @@ class ProfileControllerTest < ActionController::TestCase | ||
17 | def test_local_files_reference | 17 | def test_local_files_reference |
18 | assert_local_files_reference | 18 | assert_local_files_reference |
19 | end | 19 | end |
20 | - | 20 | + |
21 | def test_valid_xhtml | 21 | def test_valid_xhtml |
22 | assert_valid_xhtml | 22 | assert_valid_xhtml |
23 | end | 23 | end |
24 | - | 24 | + |
25 | noosfero_test :profile => 'testuser' | 25 | noosfero_test :profile => 'testuser' |
26 | 26 | ||
27 | should 'list friends' do | 27 | should 'list friends' do |
@@ -68,7 +68,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -68,7 +68,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
68 | assert_template 'members' | 68 | assert_template 'members' |
69 | assert_kind_of Array, assigns(:members) | 69 | assert_kind_of Array, assigns(:members) |
70 | end | 70 | end |
71 | - | 71 | + |
72 | should 'list favorite enterprises' do | 72 | should 'list favorite enterprises' do |
73 | get :favorite_enterprises | 73 | get :favorite_enterprises |
74 | 74 | ||
@@ -318,7 +318,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -318,7 +318,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
318 | get :profile_info, :profile => 'my-test-enterprise', :block_id => block.id | 318 | get :profile_info, :profile => 'my-test-enterprise', :block_id => block.id |
319 | assert_no_match /\/contact\/my-test-enterprise\/new/, @response.body | 319 | assert_no_match /\/contact\/my-test-enterprise\/new/, @response.body |
320 | end | 320 | end |
321 | - | 321 | + |
322 | should 'display contact button only if friends' do | 322 | should 'display contact button only if friends' do |
323 | friend = create_user_full('friend_user').person | 323 | friend = create_user_full('friend_user').person |
324 | friend.user.activate | 324 | friend.user.activate |
@@ -1091,7 +1091,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1091,7 +1091,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
1091 | login_as(profile.identifier) | 1091 | login_as(profile.identifier) |
1092 | person = fast_create(Person) | 1092 | person = fast_create(Person) |
1093 | at = fast_create(ActionTracker::Record, :user_id => person.id) | 1093 | at = fast_create(ActionTracker::Record, :user_id => person.id) |
1094 | - atn = fast_create(ActionTrackerNotification, :profile_id => profile.id, :action_tracker_id => at.id) | 1094 | + atn = fast_create(ActionTrackerNotification, :profile_id => profile.id, :action_tracker_id => at.id) |
1095 | get :index, :profile => person.identifier | 1095 | get :index, :profile => person.identifier |
1096 | assert_no_tag :tag => 'div', :attributes => {:id => 'profile-network'} | 1096 | assert_no_tag :tag => 'div', :attributes => {:id => 'profile-network'} |
1097 | 1097 | ||
@@ -1103,7 +1103,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1103,7 +1103,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
1103 | should "not show the scrap button on network activity if the user is himself" do | 1103 | should "not show the scrap button on network activity if the user is himself" do |
1104 | login_as(profile.identifier) | 1104 | login_as(profile.identifier) |
1105 | at = fast_create(ActionTracker::Record, :user_id => profile.id) | 1105 | at = fast_create(ActionTracker::Record, :user_id => profile.id) |
1106 | - atn = fast_create(ActionTrackerNotification, :profile_id => profile.id, :action_tracker_id => at.id) | 1106 | + atn = fast_create(ActionTrackerNotification, :profile_id => profile.id, :action_tracker_id => at.id) |
1107 | get :index, :profile => profile.identifier | 1107 | get :index, :profile => profile.identifier |
1108 | assert_no_tag :tag => 'p', :attributes => {:class => 'profile-network-send-message'} | 1108 | assert_no_tag :tag => 'p', :attributes => {:class => 'profile-network-send-message'} |
1109 | end | 1109 | end |
@@ -1131,7 +1131,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1131,7 +1131,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
1131 | at = fast_create(ActionTracker::Record, :user_id => profile.id) | 1131 | at = fast_create(ActionTracker::Record, :user_id => profile.id) |
1132 | profile.public_profile=false | 1132 | profile.public_profile=false |
1133 | profile.save | 1133 | profile.save |
1134 | - atn = fast_create(ActionTrackerNotification, :profile_id => profile.id, :action_tracker_id => at.id) | 1134 | + atn = fast_create(ActionTrackerNotification, :profile_id => profile.id, :action_tracker_id => at.id) |
1135 | get :index, :profile => profile.identifier | 1135 | get :index, :profile => profile.identifier |
1136 | assert_equal [at], profile.tracked_actions | 1136 | assert_equal [at], profile.tracked_actions |
1137 | assert_no_tag :tag => 'li', :attributes => {:id => "profile-activity-item-#{atn.id}"} | 1137 | assert_no_tag :tag => 'li', :attributes => {:id => "profile-activity-item-#{atn.id}"} |
@@ -1276,7 +1276,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1276,7 +1276,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
1276 | login_as(profile.identifier) | 1276 | login_as(profile.identifier) |
1277 | get :index, :profile => profile.identifier | 1277 | get :index, :profile => profile.identifier |
1278 | 1278 | ||
1279 | - assert_tag :tag => 'p', :content => 'A scrap', :attributes => { :class => 'profile-activity-text'} | 1279 | + assert_tag :tag => 'p', :content => 'A scrap', :attributes => { :class => 'profile-activity-text'} |
1280 | assert_tag :tag => 'div', :attributes => { :class => 'profile-activity-lead' }, :descendant => { :tag => 'a', :content => 'An article about free software' } | 1280 | assert_tag :tag => 'div', :attributes => { :class => 'profile-activity-lead' }, :descendant => { :tag => 'a', :content => 'An article about free software' } |
1281 | end | 1281 | end |
1282 | 1282 | ||
@@ -1549,7 +1549,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1549,7 +1549,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
1549 | assert_tag :tag => 'td', :content => 'e-Mail:' | 1549 | assert_tag :tag => 'td', :content => 'e-Mail:' |
1550 | end | 1550 | end |
1551 | 1551 | ||
1552 | - should 'build menu to the community panel' do | 1552 | + should 'build menu to the community panel if enabled' do |
1553 | u = create_user('other_other_ze').person | 1553 | u = create_user('other_other_ze').person |
1554 | u2 = create_user('guy_that_will_be_admin_of_all').person # because the first member of each community is an admin | 1554 | u2 = create_user('guy_that_will_be_admin_of_all').person # because the first member of each community is an admin |
1555 | Environment.any_instance.stubs(:required_person_fields).returns([]) | 1555 | Environment.any_instance.stubs(:required_person_fields).returns([]) |
@@ -1582,6 +1582,12 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1582,6 +1582,12 @@ class ProfileControllerTest < ActionController::TestCase | ||
1582 | assert_no_match /community_3/, links.to_s | 1582 | assert_no_match /community_3/, links.to_s |
1583 | assert_no_match /community_4/, links.to_s | 1583 | assert_no_match /community_4/, links.to_s |
1584 | end | 1584 | end |
1585 | + | ||
1586 | + Environment.any_instance.stubs(:enabled?).returns(false) | ||
1587 | + Environment.any_instance.stubs(:enabled?).with('disable_my_communities_menu').returns(true) | ||
1588 | + | ||
1589 | + get :index | ||
1590 | + assert_no_tag :tag => 'div', :attributes => {:id => 'manage-communities'} | ||
1585 | end | 1591 | end |
1586 | 1592 | ||
1587 | should 'build menu to the enterprise panel' do | 1593 | should 'build menu to the enterprise panel' do |