Commit e59c8ae2a2c1366e562831c6b6d15d87c71b99f4

Authored by Rodrigo Souto
1 parent 0cddc2c3

product-categories-block: not visible when products are disabled on the environment

app/models/product_categories_block.rb
... ... @@ -33,4 +33,8 @@ class ProductCategoriesBlock < Block
33 33 end
34 34 end
35 35  
  36 + def visible?(context=nil)
  37 + box.environment.enabled?('products_for_enterprises')
  38 + end
  39 +
36 40 end
... ...
test/unit/product_categories_block_test.rb 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +require File.dirname(__FILE__) + '/../test_helper'
  2 +
  3 +class ProductCategoriesBlockTest < ActiveSupport::TestCase
  4 + should 'not be visible if products are disabled on the environment ' do
  5 + enterprise = fast_create(Enterprise)
  6 + box = fast_create(Box, :owner_id => enterprise.id, :owner_type => 'Profile')
  7 + block = ProductCategoriesBlock.new
  8 + block.box = box
  9 +
  10 + block.box.environment.enable('products_for_enterprises')
  11 + assert block.visible?
  12 +
  13 + block.box.environment.disable('products_for_enterprises')
  14 + assert !block.visible?
  15 + end
  16 +end
... ...