Sha256: b1e997ce18132d207687455ec7a297d096bedacbc5116ffe0e8b4a758a5ae8b5

Contents?: true

Size: 1.63 KB

Versions: 62

Compression:

Stored size: 1.63 KB

Contents

require 'test_helper'

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

      def test_updates_a_discount
        discount = create_shipping_discount(
          name: 'Test Discount',
          active: true,
          shipping_service: 'Ground',
          amount: 5
        )

        patch admin.pricing_discount_path(discount),
          params: {
            discount: {
              name: 'Edit Test Discount',
              shipping_service: 'Next Day',
              amount: 4
            }
          }

        discount.reload
        assert_equal('Edit Test Discount', discount.name)
        assert_equal('Next Day', discount.shipping_service)
        assert_equal(4.to_m, discount.amount)
      end

      def test_removes_a_discount
        discount = create_shipping_discount(
          name: 'Test Discount',
          active: true,
          shipping_service: 'Ground',
          amount: 5
        )

        delete admin.pricing_discount_path(discount)
        assert(Pricing::Discount.empty?)
      end

      def test_autocompletes_partial_queries_when_xhr
        discount = create_product_discount(name: 'Test')
        create_top_discounts(results: [{ discount_id: discount.id }])

        get admin.pricing_discounts_path(format: 'json', q: 'tes'), xhr: true

        results = JSON.parse(response.body)
        assert_equal(1, results['results'].length)
        assert(results['results'].first['label'].present?)
        assert_equal(discount.id.to_s, results['results'].first['value'])
        assert(results['results'].first['top'])
      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/discounts_integration_test.rb
workarea-admin-3.5.26 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.4.45 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.5.25 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.5.23 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.4.44 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.5.22 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.4.43 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.5.21 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.4.42 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.5.20 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.4.41 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.5.19 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.4.40 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.5.18 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.4.39 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.5.17 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.4.38 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.5.16 test/integration/workarea/admin/discounts_integration_test.rb
workarea-admin-3.4.37 test/integration/workarea/admin/discounts_integration_test.rb