Sha256: 33a62b7d04d9649567cf56f5e1c00d44caa3482fdadad6a2d186633738cee961

Contents?: true

Size: 1.71 KB

Versions: 34

Compression:

Stored size: 1.71 KB

Contents

require 'test_helper'

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

      def order
        @order ||= create_order
      end

      def test_setting_price_overrides_for_an_order
        patch admin.pricing_override_path(order.id),
          params: {
            override: {
              subtotal_adjustment: '10.00',
              shipping_adjustment: '1.00'
            }
          }

        assert_redirected_to(storefront.cart_path)

        override = Pricing::Override.first
        assert_equal(-10.to_m, override.subtotal_adjustment)
        assert_equal(-1.to_m, override.shipping_adjustment)
      end

      def test_setting_item_price_overrides_for_an_order
        patch admin.pricing_override_path(order.id),
          params: {
            override: {
              item_prices: {
                '123' => '5.25',
                '234' => ''
              },
              shipping_adjustment: '1.00'
            }
          }

        assert_redirected_to(storefront.cart_path)

        override = Pricing::Override.first
        assert_equal(-1.to_m, override.shipping_adjustment)
        assert_equal(5.25.to_m, override.item_price_for_id('123'))
        assert_nil(override.item_price_for_id('234'))
      end

      def test_creating_a_comment_with_overrides
        patch admin.pricing_override_path(order.id),
          params: {
            override: {
              subtotal_adjustment: '10.00',
              shipping_adjustment: '1.00'
            },
            comment: 'test comment'
          }

        assert_equal(1, Pricing::Override.count)
        assert_equal(1, order.reload.comments.count)
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-admin-3.4.45 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.44 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.43 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.42 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.41 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.40 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.39 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.38 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.37 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.36 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.35 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.34 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.33 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.32 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.31 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.30 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.29 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.28 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.27 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.26 test/integration/workarea/admin/pricing_overrides_integration_test.rb