From e59c8ae2a2c1366e562831c6b6d15d87c71b99f4 Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Tue, 21 Jan 2014 19:34:30 +0000 Subject: [PATCH] product-categories-block: not visible when products are disabled on the environment --- app/models/product_categories_block.rb | 4 ++++ test/unit/product_categories_block_test.rb | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 0 deletions(-) create mode 100644 test/unit/product_categories_block_test.rb 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