Sha256: 67cc74aa7f8cd50e13b6374e1859617d2659eb54d23a267d50f4dc290f605ec7

Contents?: true

Size: 1.27 KB

Versions: 62

Compression:

Stored size: 1.27 KB

Contents

require 'test_helper'

module Workarea
  class ProductPrimaryNavigationTest < IntegrationTest
    setup :set_product
    setup :set_categories
    setup :set_taxonomy

    def set_product
      @product = create_product
    end

    def set_categories
      @category_one = create_category(
        name: 'Oldest',
        created_at: 1.day.ago,
        product_ids: [@product.id]
      )

      @category_two = create_category(product_ids: [@product.id])
    end

    def set_taxonomy
      @primary_1 = create_taxon(name: 'Primary')
      @child_1 = create_taxon(parent: @primary_1, navigable: @category_one)
      @child_2 = create_taxon(parent: @child_1, navigable: @category_two)
    end

    def test_highest_category
      highest_category = ProductPrimaryNavigation.new(@product).highest_category
      assert_equal(@category_one.id, highest_category.id)
    end

    def test_oldest_category
      oldest_category = ProductPrimaryNavigation.new(@product).oldest_category
      assert_equal(@category_one.id, oldest_category.id)
    end

    def test_name
      name = ProductPrimaryNavigation.new(@product).name
      assert_equal('Primary', name)

      Navigation::Taxon.delete_all

      name = ProductPrimaryNavigation.new(@product).name
      assert_equal('Oldest', name)
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.5.26 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.4.45 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.5.25 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.5.23 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.4.44 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.5.22 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.4.43 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.5.21 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.4.42 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.5.20 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.4.41 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.5.19 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.4.40 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.5.18 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.4.39 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.5.17 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.4.38 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.5.16 test/queries/workarea/product_primary_navigation_test.rb
workarea-core-3.4.37 test/queries/workarea/product_primary_navigation_test.rb