Sha256: e43f8d966ee638fe87f2a85f4f851c88eef13210df4d9281d470feeb09b0788d

Contents?: true

Size: 1.85 KB

Versions: 62

Compression:

Stored size: 1.85 KB

Contents

require 'test_helper'

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

      def test_adding_a_product
        product = create_product
        category = create_category(product_ids: [])
        post admin.add_featured_product_path(category.to_global_id),
              params: { product_id: product.id }

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

      def test_adding_a_product_without_publishing_authorization
        product = create_product
        category = create_category(product_ids: [])

        set_current_user(create_user(
                           admin: true,
                           releases_access: true,
                           catalog_access: true,
                           can_publish_now: false
        ))

        post admin.add_featured_product_path(category.to_global_id),
              params: { product_id: product.id },
              headers: { 'HTTP_REFERER' => admin.featured_product_path(category.to_global_id) }


        assert_equal([], category.reload.product_ids)
        assert_redirected_to(admin.featured_product_path(category.to_global_id))
        assert_equal(flash[:error], I18n.t('workarea.admin.publish_authorization.unauthorized'))

        category.update_attributes!(active: false)

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

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

      def test_removing_a_product
        product = create_product
        category = create_category(product_ids: [product.id])
        delete admin.remove_featured_product_path(category.to_global_id),
                params: { product_id: product.id }

        assert_equal([], category.reload.product_ids)
      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/featured_products_integration_test.rb
workarea-admin-3.5.26 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.4.45 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.5.25 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.5.23 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.4.44 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.5.22 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.4.43 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.5.21 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.4.42 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.5.20 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.4.41 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.5.19 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.4.40 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.5.18 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.4.39 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.5.17 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.4.38 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.5.16 test/integration/workarea/admin/featured_products_integration_test.rb
workarea-admin-3.4.37 test/integration/workarea/admin/featured_products_integration_test.rb