Module: Workarea::FeaturedProductsTest

Defined in:
lib/workarea/core/featured_products_test.rb

Instance Method Summary collapse

Instance Method Details

#test_adding_a_productObject



3
4
5
6
7
8
9
10
11
# File 'lib/workarea/core/featured_products_test.rb', line 3

def test_adding_a_product
  featured_product_model.add_product('foo')
  assert_includes(featured_product_model.reload.product_ids, 'foo')
  assert(featured_product_model.featured_product?('foo'))

  featured_product_model.add_product('bar')
  assert_equal('bar', featured_product_model.reload.product_ids.first)
  assert(featured_product_model.featured_product?('bar'))
end

#test_cleaning_product_idsObject



20
21
22
23
24
25
26
27
28
# File 'lib/workarea/core/featured_products_test.rb', line 20

def test_cleaning_product_ids
  ['', nil].each do |blank|
    featured_product_model.add_product(blank)
    assert_equal(0, featured_product_model.reload.product_ids.length)
  end

  2.times { featured_product_model.add_product('foo') }
  assert_equal(['foo'], featured_product_model.reload.product_ids)
end

#test_removing_a_productObject



13
14
15
16
17
18
# File 'lib/workarea/core/featured_products_test.rb', line 13

def test_removing_a_product
  featured_product_model.add_product('foo')
  featured_product_model.remove_product('foo')
  assert_empty(featured_product_model.reload.product_ids)
  refute(featured_product_model.featured_product?('foo'))
end