Sha256: 5afc37d3ccd6a04a7299d75f8a6ea8859ba45b81b35525721563ce35822c9eb3

Contents?: true

Size: 950 Bytes

Versions: 3

Compression:

Stored size: 950 Bytes

Contents

require 'test_helper'

module Workarea
  decorate Storefront::CategoryViewModelTest, with: :product_grid_content do
    def test_content
      products = [
        create_product(name: 'Foo 1', filters: { 'color' => 'Red' }),
        create_product(name: 'Foo 2', filters: { 'color' => 'Green' })
      ]

      BulkIndexProducts.perform_by_models(products)
      @category.product_rules.create!(
        name: 'search',
        operator: 'equals',
        value: 'foo'
      )

      content = Content.for(@category)
      content.blocks.create!(
        area: 'in_grid',
        type: 'product_grid_cell',
        data: { position: '1' }
      )
      view_model = Storefront::CategoryViewModel.new(@category)

      assert_equal(1, view_model.product_grid_content_blocks.count)
      assert_equal(content.blocks.first, view_model.product_grid_content_for(0).first.model)
      assert_equal(0, view_model.product_position_offset)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-product_grid_content-1.4.0 test/view_models/workarea/storefront/category_view_model_test.decorator
workarea-product_grid_content-1.3.1 test/view_models/workarea/storefront/category_view_model_test.decorator
workarea-product_grid_content-1.3.0 test/view_models/workarea/storefront/category_view_model_test.decorator