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.25 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.24 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.23 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.22 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.21 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.20 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.19 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.18 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.17 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.16 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.15 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.14 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.13 test/integration/workarea/admin/pricing_overrides_integration_test.rb
workarea-admin-3.4.12 test/integration/workarea/admin/pricing_overrides_integration_test.rb