diff --git a/app/models/product_categories_block.rb b/app/models/product_categories_block.rb index 608a5ea..47c2f61 100644 --- a/app/models/product_categories_block.rb +++ b/app/models/product_categories_block.rb @@ -33,4 +33,8 @@ class ProductCategoriesBlock < Block end end + def visible?(context=nil) + box.environment.enabled?('products_for_enterprises') + end + end diff --git a/test/unit/product_categories_block_test.rb b/test/unit/product_categories_block_test.rb new file mode 100644 index 0000000..74382f0 --- /dev/null +++ b/test/unit/product_categories_block_test.rb @@ -0,0 +1,16 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class ProductCategoriesBlockTest < ActiveSupport::TestCase + should 'not be visible if products are disabled on the environment ' do + enterprise = fast_create(Enterprise) + box = fast_create(Box, :owner_id => enterprise.id, :owner_type => 'Profile') + block = ProductCategoriesBlock.new + block.box = box + + block.box.environment.enable('products_for_enterprises') + assert block.visible? + + block.box.environment.disable('products_for_enterprises') + assert !block.visible? + end +end -- libgit2 0.21.2