Sha256: cae6c0384b335761937fb3640069da579cef402347c6aca74e1d3d5e83975739

Contents?: true

Size: 1.46 KB

Versions: 14

Compression:

Stored size: 1.46 KB

Contents

require 'test_helper'

module Workarea
  module Search
    class StorefrontTest < TestCase
      def test_active
        model = create_product(active: false)
        refute(Storefront.new(model).active[:now])

        model.update!(active: true)
        assert(Storefront.new(model).active[:now])
      end

      def test_changesets
        category = create_category(
          name: 'Foo',
          product_rules: [{ name: 'search', operator: 'equals', value: 'foo' }]
        )
        assert_empty(Storefront.new(category).changesets)

        release = create_release
        release.as_current { category.update!(name: 'Bar') }
        assert_equal(1, Storefront.new(category).changesets.size)

        release.as_current { category.product_rules.first.update!(value: 'bar') }
        assert_equal(2, Storefront.new(category).changesets.size)
      end

      def test_releases
        category = create_category(name: 'Foo')
        assert_empty(Storefront.new(category).as_document[:changeset_release_ids])

        a = create_release(publish_at: 1.week.from_now)
        a.as_current { category.update!(name: 'Bar') }
        assert_equal([a.id], Storefront.new(category).as_document[:changeset_release_ids])

        b = create_release(publish_at: 2.weeks.from_now)
        assert_includes(Storefront.new(category).as_document[:changeset_release_ids], a.id)
        assert_includes(Storefront.new(category).as_document[:changeset_release_ids], b.id)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/models/workarea/search/storefront_test.rb
workarea-core-3.5.26 test/models/workarea/search/storefront_test.rb
workarea-core-3.5.25 test/models/workarea/search/storefront_test.rb
workarea-core-3.5.23 test/models/workarea/search/storefront_test.rb
workarea-core-3.5.22 test/models/workarea/search/storefront_test.rb
workarea-core-3.5.21 test/models/workarea/search/storefront_test.rb
workarea-core-3.5.20 test/models/workarea/search/storefront_test.rb
workarea-core-3.5.19 test/models/workarea/search/storefront_test.rb
workarea-core-3.5.18 test/models/workarea/search/storefront_test.rb
workarea-core-3.5.17 test/models/workarea/search/storefront_test.rb
workarea-core-3.5.16 test/models/workarea/search/storefront_test.rb
workarea-core-3.5.15 test/models/workarea/search/storefront_test.rb
workarea-core-3.5.14 test/models/workarea/search/storefront_test.rb
workarea-core-3.5.13 test/models/workarea/search/storefront_test.rb