Sha256: 1833003af6d2ac377101b2cd9795833a498698523c67616fb79dd510575bb6d5

Contents?: true

Size: 1.49 KB

Versions: 62

Compression:

Stored size: 1.49 KB

Contents

require 'test_helper'

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

      setup :set_models

      def set_models
        @product = create_product
        @category_one = create_category
        @category_two = create_category
        @category_three = create_category
      end

      def test_creation
        post admin.catalog_product_categorizations_path(@product),
          params: { category_ids: [@category_one.id, @category_two.id] }

        @category_one.reload
        @category_two.reload

        assert(@category_one.featured_product?(@product.id))
        assert(@category_two.featured_product?(@product.id))
      end

      def test_deletion
        @category_one.add_product(@product.id)
        delete admin.catalog_product_categorization_path(@product, @category_one)

        @category_one.reload
        refute(@category_one.featured_product?(@product.id))
      end

      def test_listing_default_category_candidates
        post admin.catalog_product_categorizations_path(@product),
          params: { category_ids: [@category_one.id, @category_three.id] }

        get admin.catalog_product_categorizations_path(@product, format: :json), xhr: true

        results = JSON.parse(response.body)
        assert(2, results['results'].length)
        assert(results['results'].first['value'], @category_one.id);
        assert(results['results'].last['value'], @category_three.id);
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

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