Sha256: 242b16a1d1be2f589e2d6c9854b72d0013497c9e8a770d345c6e0e34e289acf9

Contents?: true

Size: 750 Bytes

Versions: 20

Compression:

Stored size: 750 Bytes

Contents

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

  factory :tax_adjustment, class: Spree::Adjustment do
    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

20 entries across 20 versions & 1 rubygems

Version Path
spree_core-3.4.6 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.2.9 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.6.6 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.6.5 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.6.4 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.6.3 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.6.2 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.6.1 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.6.0 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.5.0 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.3.6 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.2.8 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.6.0.rc1 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.5.0.rc2 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.5.0.rc1 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.4.5 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.3.5 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.4.4 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.4.3 lib/spree/testing_support/factories/adjustment_factory.rb
spree_core-3.4.2 lib/spree/testing_support/factories/adjustment_factory.rb