Commit 0fbd1b38cff72dcc6abc155bd73aa1e32fdc9ae5

Authored by Daniela Feitosa
2 parents 223c8d39 da23338a

Merge remote branch 'larissa/makes-my-community-opicional'

app/helpers/application_helper.rb
... ... @@ -1134,12 +1134,12 @@ module ApplicationHelper
1134 1134 end
1135 1135  
1136 1136 def manage_enterprises
1137   - return if not user
  1137 + return unless user
1138 1138 manage_link(user.enterprises, :enterprises)
1139 1139 end
1140 1140  
1141 1141 def manage_communities
1142   - return if not user
  1142 + return unless user && !user.environment.enabled?('disable_my_communities_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
... ... @@ -97,6 +97,7 @@ class Environment < ActiveRecord::Base
97 97 'disable_asset_events' => _('Disable search for events'),
98 98 'disable_categories' => _('Disable categories'),
99 99 'disable_header_and_footer' => _('Disable header/footer editing by users'),
  100 + 'disable_my_communities_menu' => _('Disable My Communities menu'),
100 101 'disable_gender_icon' => _('Disable gender icon'),
101 102 'disable_categories_menu' => _('Disable the categories menu'),
102 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 17 def test_local_files_reference
18 18 assert_local_files_reference
19 19 end
20   -
  20 +
21 21 def test_valid_xhtml
22 22 assert_valid_xhtml
23 23 end
24   -
  24 +
25 25 noosfero_test :profile => 'testuser'
26 26  
27 27 should 'list friends' do
... ... @@ -68,7 +68,7 @@ class ProfileControllerTest < ActionController::TestCase
68 68 assert_template 'members'
69 69 assert_kind_of Array, assigns(:members)
70 70 end
71   -
  71 +
72 72 should 'list favorite enterprises' do
73 73 get :favorite_enterprises
74 74  
... ... @@ -318,7 +318,7 @@ class ProfileControllerTest < ActionController::TestCase
318 318 get :profile_info, :profile => 'my-test-enterprise', :block_id => block.id
319 319 assert_no_match /\/contact\/my-test-enterprise\/new/, @response.body
320 320 end
321   -
  321 +
322 322 should 'display contact button only if friends' do
323 323 friend = create_user_full('friend_user').person
324 324 friend.user.activate
... ... @@ -1091,7 +1091,7 @@ class ProfileControllerTest < ActionController::TestCase
1091 1091 login_as(profile.identifier)
1092 1092 person = fast_create(Person)
1093 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 1095 get :index, :profile => person.identifier
1096 1096 assert_no_tag :tag => 'div', :attributes => {:id => 'profile-network'}
1097 1097  
... ... @@ -1103,7 +1103,7 @@ class ProfileControllerTest < ActionController::TestCase
1103 1103 should "not show the scrap button on network activity if the user is himself" do
1104 1104 login_as(profile.identifier)
1105 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 1107 get :index, :profile => profile.identifier
1108 1108 assert_no_tag :tag => 'p', :attributes => {:class => 'profile-network-send-message'}
1109 1109 end
... ... @@ -1131,7 +1131,7 @@ class ProfileControllerTest < ActionController::TestCase
1131 1131 at = fast_create(ActionTracker::Record, :user_id => profile.id)
1132 1132 profile.public_profile=false
1133 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 1135 get :index, :profile => profile.identifier
1136 1136 assert_equal [at], profile.tracked_actions
1137 1137 assert_no_tag :tag => 'li', :attributes => {:id => "profile-activity-item-#{atn.id}"}
... ... @@ -1276,7 +1276,7 @@ class ProfileControllerTest < ActionController::TestCase
1276 1276 login_as(profile.identifier)
1277 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 1280 assert_tag :tag => 'div', :attributes => { :class => 'profile-activity-lead' }, :descendant => { :tag => 'a', :content => 'An article about free software' }
1281 1281 end
1282 1282  
... ... @@ -1549,7 +1549,7 @@ class ProfileControllerTest < ActionController::TestCase
1549 1549 assert_tag :tag => 'td', :content => 'e-Mail:'
1550 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 1553 u = create_user('other_other_ze').person
1554 1554 u2 = create_user('guy_that_will_be_admin_of_all').person # because the first member of each community is an admin
1555 1555 Environment.any_instance.stubs(:required_person_fields).returns([])
... ... @@ -1582,6 +1582,12 @@ class ProfileControllerTest < ActionController::TestCase
1582 1582 assert_no_match /community_3/, links.to_s
1583 1583 assert_no_match /community_4/, links.to_s
1584 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 1591 end
1586 1592  
1587 1593 should 'build menu to the enterprise panel' do
... ...