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.4.27 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.5.4 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.4.26 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.5.3 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.4.25 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.5.2 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.4.24 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.5.1 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.4.23 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.4.22 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.5.0 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.4.21 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.5.0.beta.1 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.4.20 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.4.19 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.4.18 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.4.17 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.4.16 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.4.15 test/integration/workarea/admin/categorizations_integration_test.rb
workarea-admin-3.4.14 test/integration/workarea/admin/categorizations_integration_test.rb