Sha256: e26872de29c36cfeba822e56563cf9b7a6bdbe47a3dd4ebf645b40b77cbca46c

Contents?: true

Size: 1.8 KB

Versions: 4

Compression:

Stored size: 1.8 KB

Contents

require 'test_helper'

module Workarea
  module Admin
    class BrowseOptionFeaturedProductsIntegrationTest < Workarea::IntegrationTest
      include Admin::IntegrationTest

      setup :product

      def product
        @product ||=
          create_product(
            id:          'PROD1',
            name:        'Integration Product',
            filters:     { 'Size' => %w(Medium Large), 'Color' => 'Red' },
            browse_option: 'size',
            variants:    [
              { sku: 'SKU1', regular: 5.to_m, details: { 'Size' => 'Medium' } },
              { sku: 'SKU2', regular: 5.to_m, details: { 'Size' => 'Large' } }
            ]
          )
      end

      def test_adding_a_product_that_browses_by_option
        option_id = BrowseOptionIds.for(product, 'Medium')
        category = create_category(product_ids: [])

        post admin.add_featured_product_path(category.to_global_id),
              params: { product_id: option_id }

        assert_equal([option_id], category.reload.product_ids)
      end

      def test_removing_a_product
        option_id = BrowseOptionIds.for(product, 'Medium')
        category = create_category(product_ids: [option_id])

        delete admin.remove_featured_product_path(category.to_global_id),
                params: { product_id: option_id }

        assert_equal([], category.reload.product_ids)
      end

      def test_delete_featured_products
        product = create_product
        category = create_category(product_ids: [product.id])

        get admin.catalog_category_path(category)

        assert(response.success?)

        assert(product.destroy!)

        # ActionView::Template::Error: undefined method `primary_image' for nil:NilClass
        get admin.catalog_category_path(category)

        assert(response.success?)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
workarea-browse_option-2.2.0 test/integration/workarea/admin/browse_option_featured_products_integration_test.rb
workarea-browse_option-2.1.9 test/integration/workarea/admin/browse_option_featured_products_integration_test.rb
workarea-browse_option-2.1.8 test/integration/workarea/admin/browse_option_featured_products_integration_test.rb
workarea-browse_option-2.1.7 test/integration/workarea/admin/browse_option_featured_products_integration_test.rb