Sha256: 13c683ed54a3def3095deefc2244e928494c707174591b600d1440901e4c1f73

Contents?: true

Size: 1.04 KB

Versions: 15

Compression:

Stored size: 1.04 KB

Contents

require 'spree/testing_support/factories/line_item_factory'
require 'spree/testing_support/factories/order_factory'
require 'spree/testing_support/factories/tax_category_factory'
require 'spree/testing_support/factories/tax_rate_factory'
require 'spree/testing_support/factories/zone_factory'

FactoryGirl.define do
  factory :adjustment, class: Spree::Adjustment do
    order
    adjustable { order }
    amount 100.0
    label 'Shipping'
    association(:source, factory: :tax_rate)
    eligible true
  end

  factory :tax_adjustment, class: Spree::Adjustment do
    order { adjustable.order }
    association(:adjustable, factory: :line_item)
    amount 10.0
    label 'VAT 5%'
    association(:source, factory: :tax_rate)
    eligible true

    after(:create) do |adjustment|
      # Set correct tax category, so that adjustment amount is not 0
      if adjustment.adjustable.is_a?(Spree::LineItem)
        adjustment.source.tax_category = adjustment.adjustable.tax_category
        adjustment.source.save
        adjustment.update!
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
solidus_core-1.3.2 lib/spree/testing_support/factories/adjustment_factory.rb
solidus_core-1.2.3 lib/spree/testing_support/factories/adjustment_factory.rb
solidus_core-2.0.0.beta1 lib/spree/testing_support/factories/adjustment_factory.rb
solidus_core-1.4.0.beta1 lib/spree/testing_support/factories/adjustment_factory.rb
solidus_core-1.3.1 lib/spree/testing_support/factories/adjustment_factory.rb
solidus_core-1.3.0 lib/spree/testing_support/factories/adjustment_factory.rb
solidus_core-1.3.0.rc2 lib/spree/testing_support/factories/adjustment_factory.rb
solidus_core-1.3.0.rc1 lib/spree/testing_support/factories/adjustment_factory.rb
solidus_core-1.3.0.beta1 lib/spree/testing_support/factories/adjustment_factory.rb
solidus_core-1.2.2 lib/spree/testing_support/factories/adjustment_factory.rb
solidus_core-1.2.1 lib/spree/testing_support/factories/adjustment_factory.rb
solidus_core-1.2.0 lib/spree/testing_support/factories/adjustment_factory.rb
solidus_core-1.2.0.rc2 lib/spree/testing_support/factories/adjustment_factory.rb
solidus_core-1.2.0.rc1 lib/spree/testing_support/factories/adjustment_factory.rb
solidus_core-1.2.0.beta1 lib/spree/testing_support/factories/adjustment_factory.rb