Commit 02b98139c61b2cd389eec9b453c4cd08b19ad1dc
Exists in
master
and in
29 other branches
Merge commit 'e9bde88201089e958097b22931fc7b07079af2f8' into v0.11.x
Showing
7 changed files
with
52 additions
and
3 deletions
Show diff stats
app/helpers/application_helper.rb
app/models/environment.rb
... | ... | @@ -29,6 +29,7 @@ class Environment < ActiveRecord::Base |
29 | 29 | 'disable_asset_products' => _('Disable search for products'), |
30 | 30 | 'disable_asset_events' => _('Disable search for events'), |
31 | 31 | 'disable_products_for_enterprises' => _('Disable products for enterprises'), |
32 | + 'disable_categories' => _('Disable categories'), | |
32 | 33 | } |
33 | 34 | end |
34 | 35 | ... | ... |
app/views/layouts/application.rhtml
... | ... | @@ -104,8 +104,10 @@ |
104 | 104 | { :controller=>"home" }, |
105 | 105 | :id=>"menu_link_to_envhome", |
106 | 106 | :title=>@environment.name %> |
107 | - <% cache(:controller => 'public', :action => 'categories_menu') do %> | |
108 | - <%= render :file => 'shared/categories_menu' %> | |
107 | + <% unless environment.enabled?(:disable_categories) %> | |
108 | + <% cache(:controller => 'public', :action => 'categories_menu') do %> | |
109 | + <%= render :file => 'shared/categories_menu' %> | |
110 | + <% end %> | |
109 | 111 | <% end %> |
110 | 112 | <%= render :file => 'shared/assets_menu' %> |
111 | 113 | </div><!-- id='navigation_bar' --> | ... | ... |
test/functional/application_controller_test.rb
... | ... | @@ -305,4 +305,12 @@ class ApplicationControllerTest < Test::Unit::TestCase |
305 | 305 | assert_response :success |
306 | 306 | end |
307 | 307 | |
308 | + should 'not display categories menu if categories feature disabled' do | |
309 | + Environment.any_instance.stubs(:enabled?).with(anything).returns(true) | |
310 | + c1 = Environment.default.categories.create!(:name => 'Category 1', :display_color => 1, :parent => nil, :display_in_menu => true ) | |
311 | + c2 = Environment.default.categories.create!(:name => 'Category 2', :display_color => nil, :parent => c1, :display_in_menu => true ) | |
312 | + get :index | |
313 | + assert_no_tag :tag => 'a', :content => /Category 2/ | |
314 | + end | |
315 | + | |
308 | 316 | end | ... | ... |
test/functional/cms_controller_test.rb
... | ... | @@ -616,4 +616,18 @@ class CmsControllerTest < Test::Unit::TestCase |
616 | 616 | assert_redirected_to :protocol => 'https://' |
617 | 617 | end |
618 | 618 | |
619 | + should 'display categories if environment disable_categories disabled' do | |
620 | + Environment.any_instance.stubs(:enabled?).with(anything).returns(false) | |
621 | + a = profile.articles.create!(:name => 'test') | |
622 | + get :edit, :profile => profile.identifier, :id => a.id | |
623 | + assert_tag :tag => 'div', :descendant => { :tag => 'h4', :content => 'Categorize your article' } | |
624 | + end | |
625 | + | |
626 | + should 'not display categories if environment disable_categories enabled' do | |
627 | + Environment.any_instance.stubs(:enabled?).with(anything).returns(true) | |
628 | + a = profile.articles.create!(:name => 'test') | |
629 | + get :edit, :profile => profile.identifier, :id => a.id | |
630 | + assert_no_tag :tag => 'div', :descendant => { :tag => 'h4', :content => 'Categorize your article' } | |
631 | + end | |
632 | + | |
619 | 633 | end | ... | ... |
test/functional/profile_editor_controller_test.rb
... | ... | @@ -236,7 +236,7 @@ class ProfileEditorControllerTest < Test::Unit::TestCase |
236 | 236 | should 'show edit profile button' do |
237 | 237 | person = create_user('testuser').person |
238 | 238 | get :index, :profile => 'testuser' |
239 | - assert_tag :tag => 'a', :content => 'Edit Profile' | |
239 | + assert_tag :tag => 'div', :attributes => { :class => 'file-manager-button' }, :child => { :tag => 'a', :attributes => { :href => '/myprofile/testuser/profile_editor/edit' } } | |
240 | 240 | end |
241 | 241 | |
242 | 242 | should 'show image field on edit profile' do |
... | ... | @@ -495,4 +495,18 @@ class ProfileEditorControllerTest < Test::Unit::TestCase |
495 | 495 | assert_no_tag :tag => 'span', :content => 'Manage Products and Services' |
496 | 496 | end |
497 | 497 | |
498 | + should 'display categories if environment disable_categories disabled' do | |
499 | + Environment.any_instance.stubs(:enabled?).with(anything).returns(false) | |
500 | + person = User.create(:login => 'test_profile', :email => 'test@noosfero.org', :password => 'test', :password_confirmation => 'test').person | |
501 | + get :edit, :profile => person.identifier | |
502 | + assert_tag :tag => 'div', :descendant => { :tag => 'h2', :content => 'Select the categories of your interest' } | |
503 | + end | |
504 | + | |
505 | + should 'not display categories if environment disable_categories enabled' do | |
506 | + Environment.any_instance.stubs(:enabled?).with(anything).returns(true) | |
507 | + person = User.create(:login => 'test_profile', :email => 'test@noosfero.org', :password => 'test', :password_confirmation => 'test').person | |
508 | + get :edit, :profile => person.identifier | |
509 | + assert_no_tag :tag => 'div', :descendant => { :tag => 'h2', :content => 'Select the categories of your interest' } | |
510 | + end | |
511 | + | |
498 | 512 | end | ... | ... |
test/unit/application_helper_test.rb
... | ... | @@ -231,6 +231,15 @@ class ApplicationHelperTest < Test::Unit::TestCase |
231 | 231 | assert_equal "LALALA", login_url |
232 | 232 | end |
233 | 233 | |
234 | + should 'return nil if disable_categories is enabled' do | |
235 | + env = Environment.create!(:name => 'env test') | |
236 | + stubs(:environment).returns(env) | |
237 | + assert_not_nil env | |
238 | + env.enable(:disable_categories) | |
239 | + assert env.enabled?(:disable_categories) | |
240 | + assert_nil select_categories(mock) | |
241 | + end | |
242 | + | |
234 | 243 | protected |
235 | 244 | |
236 | 245 | def content_tag(tag, content, options = {}) | ... | ... |