Sha256: 6aa743c17ea1b3311b6941bd8264902c073e85e89fb128074a89126896456bbb

Contents?: true

Size: 1.66 KB

Versions: 18

Compression:

Stored size: 1.66 KB

Contents

require 'test_helper'

module Workarea
  module Search
    class ProductEntriesTest < TestCase
      def test_entries
        products = Array.new(3) { create_product }

        assert_equal(1, ProductEntries.new(products.first).entries.size)
        assert_equal(3, ProductEntries.new(products).entries.size)
      end

      def test_live_entries
        product = create_product(name: 'Foo')
        create_release.as_current do
          product.update!(name: 'Bar')
          product.reload
        end
        assert_equal('Bar', product.name)

        results = ProductEntries.new(product).live_entries
        assert_equal(1, results.size)
        assert_equal('Foo', results.first.model.name)
        refute_equal(product.object_id, results.first.model.object_id)
      end

      def test_release_entries
        product = create_product(name: 'Foo')
        release = create_release
        release.as_current { product.update!(name: 'Bar') }
        assert_equal('Foo', product.name)

        results = ProductEntries.new(product).release_entries
        assert_equal(1, results.size)
        assert_equal('Bar', results.first.model.name)
        assert_equal(release.id, results.first.release_id)
        refute_equal(product.object_id, results.first.model.object_id)
      end

      def test_entry_flattening
        products = Array.new(2) { create_product }
        release = create_release
        release.as_current { products.first.update!(name: 'Bar') }

        instance = ProductEntries.new(products)
        instance.stubs(:index_entries_for).returns([:foo, :bar])

        assert_equal([:foo, :bar, :foo, :bar, :foo, :bar], instance.entries)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.26 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.25 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.23 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.22 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.21 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.20 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.19 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.18 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.17 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.16 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.15 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.14 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.13 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.12 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.11 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.10 test/queries/workarea/search/product_entries_test.rb
workarea-core-3.5.9 test/queries/workarea/search/product_entries_test.rb