solidus_core 2.11.4 → 2.11.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_core might be problematic. Click here for more details.

Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/spree/address.rb +28 -5
  3. data/app/models/spree/order_merger.rb +1 -1
  4. data/app/models/spree/payment.rb +10 -3
  5. data/app/models/spree/product.rb +8 -2
  6. data/app/models/spree/shipping_method.rb +1 -1
  7. data/app/models/spree/stock/availability_validator.rb +2 -2
  8. data/app/models/spree/stock/inventory_validator.rb +2 -2
  9. data/app/models/spree/taxon/active_storage_attachment.rb +1 -2
  10. data/app/models/spree/taxon/paperclip_attachment.rb +1 -0
  11. data/db/migrate/20210122110141_add_name_to_spree_addresses.rb +13 -0
  12. data/lib/generators/spree/dummy/templates/rails/test.rb +3 -0
  13. data/lib/spree/core.rb +0 -4
  14. data/lib/spree/core/engine.rb +6 -7
  15. data/lib/spree/core/version.rb +1 -1
  16. data/lib/spree/testing_support.rb +19 -28
  17. data/lib/spree/testing_support/dummy_app.rb +4 -2
  18. data/lib/spree/testing_support/dummy_app/mailer_previews/test_mailer_preview.rb +4 -0
  19. data/lib/spree/testing_support/factories.rb +8 -2
  20. data/lib/spree/testing_support/factories/address_factory.rb +6 -2
  21. data/lib/spree/testing_support/factories/adjustment_factory.rb +10 -2
  22. data/lib/spree/testing_support/factories/adjustment_reason_factory.rb +4 -2
  23. data/lib/spree/testing_support/factories/calculator_factory.rb +4 -2
  24. data/lib/spree/testing_support/factories/carton_factory.rb +7 -2
  25. data/lib/spree/testing_support/factories/country_factory.rb +4 -2
  26. data/lib/spree/testing_support/factories/credit_card_factory.rb +4 -2
  27. data/lib/spree/testing_support/factories/customer_return_factory.rb +8 -2
  28. data/lib/spree/testing_support/factories/image_factory.rb +4 -2
  29. data/lib/spree/testing_support/factories/inventory_unit_factory.rb +9 -2
  30. data/lib/spree/testing_support/factories/line_item_factory.rb +7 -2
  31. data/lib/spree/testing_support/factories/option_type_factory.rb +7 -2
  32. data/lib/spree/testing_support/factories/option_value_factory.rb +4 -2
  33. data/lib/spree/testing_support/factories/order_factory.rb +11 -2
  34. data/lib/spree/testing_support/factories/order_promotion_factory.rb +7 -2
  35. data/lib/spree/testing_support/factories/payment_factory.rb +9 -2
  36. data/lib/spree/testing_support/factories/payment_method_factory.rb +4 -2
  37. data/lib/spree/testing_support/factories/price_factory.rb +6 -2
  38. data/lib/spree/testing_support/factories/product_factory.rb +10 -2
  39. data/lib/spree/testing_support/factories/product_option_type_factory.rb +7 -2
  40. data/lib/spree/testing_support/factories/product_property_factory.rb +7 -2
  41. data/lib/spree/testing_support/factories/promotion_category_factory.rb +4 -2
  42. data/lib/spree/testing_support/factories/promotion_code_factory.rb +7 -2
  43. data/lib/spree/testing_support/factories/promotion_factory.rb +7 -2
  44. data/lib/spree/testing_support/factories/property_factory.rb +4 -2
  45. data/lib/spree/testing_support/factories/refund_factory.rb +7 -2
  46. data/lib/spree/testing_support/factories/refund_reason_factory.rb +4 -2
  47. data/lib/spree/testing_support/factories/reimbursement_factory.rb +6 -2
  48. data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +4 -2
  49. data/lib/spree/testing_support/factories/return_authorization_factory.rb +8 -2
  50. data/lib/spree/testing_support/factories/return_item_factory.rb +8 -2
  51. data/lib/spree/testing_support/factories/return_reason_factory.rb +4 -2
  52. data/lib/spree/testing_support/factories/role_factory.rb +4 -2
  53. data/lib/spree/testing_support/factories/shipment_factory.rb +9 -2
  54. data/lib/spree/testing_support/factories/shipping_category_factory.rb +4 -2
  55. data/lib/spree/testing_support/factories/shipping_method_factory.rb +8 -2
  56. data/lib/spree/testing_support/factories/shipping_rate_factory.rb +7 -2
  57. data/lib/spree/testing_support/factories/state_factory.rb +7 -2
  58. data/lib/spree/testing_support/factories/stock_item_factory.rb +7 -2
  59. data/lib/spree/testing_support/factories/stock_location_factory.rb +8 -2
  60. data/lib/spree/testing_support/factories/stock_movement_factory.rb +6 -2
  61. data/lib/spree/testing_support/factories/stock_package_factory.rb +7 -2
  62. data/lib/spree/testing_support/factories/store_credit_category_factory.rb +4 -2
  63. data/lib/spree/testing_support/factories/store_credit_event_factory.rb +7 -2
  64. data/lib/spree/testing_support/factories/store_credit_factory.rb +8 -2
  65. data/lib/spree/testing_support/factories/store_credit_reason_factory.rb +4 -2
  66. data/lib/spree/testing_support/factories/store_credit_type_factory.rb +4 -2
  67. data/lib/spree/testing_support/factories/store_factory.rb +4 -2
  68. data/lib/spree/testing_support/factories/tax_category_factory.rb +7 -2
  69. data/lib/spree/testing_support/factories/tax_rate_factory.rb +8 -2
  70. data/lib/spree/testing_support/factories/taxon_factory.rb +6 -2
  71. data/lib/spree/testing_support/factories/taxonomy_factory.rb +4 -2
  72. data/lib/spree/testing_support/factories/user_factory.rb +8 -2
  73. data/lib/spree/testing_support/factories/variant_factory.rb +9 -2
  74. data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +7 -2
  75. data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +8 -2
  76. data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +7 -2
  77. data/lib/spree/testing_support/factories/zone_factory.rb +7 -2
  78. data/lib/spree/testing_support/factory_bot.rb +68 -0
  79. data/lib/spree/testing_support/order_walkthrough.rb +9 -9
  80. data/lib/spree/testing_support/sequences.rb +4 -1
  81. data/lib/tasks/migrations/migrate_address_names.rake +158 -0
  82. data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +38 -0
  83. data/lib/tasks/upgrade.rake +13 -0
  84. data/solidus_core.gemspec +23 -1
  85. metadata +30 -6
  86. data/lib/spree/awesome_nested_set_override.rb +0 -44
@@ -1,7 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/factories/calculator_factory'
8
+ require 'spree/testing_support/factories/shipping_category_factory'
9
+ require 'spree/testing_support/factories/zone_factory'
10
+ end
5
11
 
6
12
  FactoryBot.define do
7
13
  factory(
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/factories/shipping_method_factory'
8
+ require 'spree/testing_support/factories/shipment_factory'
9
+ end
5
10
 
6
11
  FactoryBot.define do
7
12
  factory :shipping_rate, class: 'Spree::ShippingRate' do
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/factories/country_factory'
8
+ end
9
+
5
10
 
6
11
  FactoryBot.define do
7
12
  factory :state, class: 'Spree::State' do
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/factories/stock_location_factory'
8
+ require 'spree/testing_support/factories/variant_factory'
9
+ end
5
10
 
6
11
  FactoryBot.define do
7
12
  factory :stock_item, class: 'Spree::StockItem' do
@@ -1,7 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/factories/country_factory'
8
+ require 'spree/testing_support/factories/state_factory'
9
+ require 'spree/testing_support/factories/product_factory'
10
+ end
5
11
 
6
12
  FactoryBot.define do
7
13
  factory :stock_location, class: 'Spree::StockLocation' do
@@ -1,7 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/factories/stock_item_factory'
8
+ end
5
9
 
6
10
  FactoryBot.define do
7
11
  factory :stock_movement, class: 'Spree::StockMovement' do
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/factories/inventory_unit_factory'
8
+ require 'spree/testing_support/factories/variant_factory'
9
+ end
5
10
 
6
11
  FactoryBot.define do
7
12
  factory :stock_package, class: 'Spree::Stock::Package' do
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+ end
5
7
 
6
8
  FactoryBot.define do
7
9
  factory :store_credit_category, class: 'Spree::StoreCreditCategory' do
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/factories/store_credit_factory'
8
+ require 'spree/testing_support/factories/store_credit_reason_factory'
9
+ end
5
10
 
6
11
  FactoryBot.define do
7
12
  factory :store_credit_event, class: 'Spree::StoreCreditEvent' do
@@ -1,7 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/factories/store_credit_category_factory'
8
+ require 'spree/testing_support/factories/store_credit_type_factory'
9
+ require 'spree/testing_support/factories/user_factory'
10
+ end
5
11
 
6
12
  FactoryBot.define do
7
13
  factory :store_credit, class: 'Spree::StoreCredit' do
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+ end
5
7
 
6
8
  FactoryBot.define do
7
9
  factory :store_credit_reason, class: 'Spree::StoreCreditReason' do
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+ end
5
7
 
6
8
  FactoryBot.define do
7
9
  factory :primary_credit_type, class: 'Spree::StoreCreditType' do
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+ end
5
7
 
6
8
  FactoryBot.define do
7
9
  factory :store, class: 'Spree::Store' do
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/sequences'
8
+ end
9
+
5
10
 
6
11
  FactoryBot.define do
7
12
  factory :tax_category, class: 'Spree::TaxCategory' do
@@ -1,7 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/factories/calculator_factory'
8
+ require 'spree/testing_support/factories/tax_category_factory'
9
+ require 'spree/testing_support/factories/zone_factory'
10
+ end
5
11
 
6
12
  FactoryBot.define do
7
13
  factory :tax_rate, class: 'Spree::TaxRate' do
@@ -1,7 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/factories/taxonomy_factory'
8
+ end
5
9
 
6
10
  FactoryBot.define do
7
11
  factory :taxon, class: 'Spree::Taxon' do
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+ end
5
7
 
6
8
  FactoryBot.define do
7
9
  factory :taxonomy, class: 'Spree::Taxonomy' do
@@ -1,7 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/sequences'
8
+ require 'spree/testing_support/factories/role_factory'
9
+ require 'spree/testing_support/factories/address_factory'
10
+ end
5
11
 
6
12
  FactoryBot.define do
7
13
  factory :user, class: Spree::UserClassHandle.new do
@@ -1,7 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/sequences'
8
+ require 'spree/testing_support/factories/option_value_factory'
9
+ require 'spree/testing_support/factories/option_type_factory'
10
+ require 'spree/testing_support/factories/product_factory'
11
+ end
5
12
 
6
13
  FactoryBot.define do
7
14
  sequence(:random_float) { BigDecimal("#{rand(200)}.#{rand(99)}") }
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/factories/option_value_factory'
8
+ require 'spree/testing_support/factories/variant_property_rule_factory'
9
+ end
5
10
 
6
11
  FactoryBot.define do
7
12
  factory :variant_property_rule_condition, class: 'Spree::VariantPropertyRuleCondition' do
@@ -1,7 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/factories/product_factory'
8
+ require 'spree/testing_support/factories/property_factory'
9
+ require 'spree/testing_support/factories/option_value_factory'
10
+ end
5
11
 
6
12
  FactoryBot.define do
7
13
  factory :variant_property_rule, class: 'Spree::VariantPropertyRule' do
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/factories/variant_property_rule_factory'
8
+ require 'spree/testing_support/factories/property_factory'
9
+ end
5
10
 
6
11
  FactoryBot.define do
7
12
  factory :variant_property_rule_value, class: 'Spree::VariantPropertyRuleValue' do
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/testing_support'
4
- Spree::TestingSupport.deprecate_cherry_picking_factory_bot_files
3
+ require 'spree/testing_support/factory_bot'
4
+ Spree::TestingSupport::FactoryBot.when_cherry_picked do
5
+ Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
6
+
7
+ require 'spree/testing_support/sequences'
8
+ require 'spree/testing_support/factories/country_factory'
9
+ end
5
10
 
6
11
  FactoryBot.define do
7
12
  factory :global_zone, class: 'Spree::Zone' do
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "factory_bot"
4
+ begin
5
+ require "factory_bot_rails"
6
+ rescue LoadError
7
+ end
8
+
9
+ module Spree
10
+ module TestingSupport
11
+ module FactoryBot
12
+ SEQUENCES = ["#{::Spree::Core::Engine.root}/lib/spree/testing_support/sequences.rb"]
13
+ FACTORIES = Dir["#{::Spree::Core::Engine.root}/lib/spree/testing_support/factories/**/*_factory.rb"].sort
14
+ PATHS = SEQUENCES + FACTORIES
15
+
16
+ def self.definition_file_paths
17
+ @paths ||= PATHS.map { |path| path.sub(/.rb\z/, '') }
18
+ end
19
+
20
+ def self.when_cherry_picked
21
+ callsites = caller
22
+
23
+ # All good if the factory is being loaded by FactoryBot or from `testing_support/factories.rb`.
24
+ return if callsites.find do |line|
25
+ line.include?("/factory_bot/find_definitions.rb") ||
26
+ line.include?("/spree/testing_support/factories.rb")
27
+ end
28
+
29
+ yield
30
+ end
31
+
32
+ def self.deprecate_cherry_picking
33
+ callsites = caller
34
+ core_root = Spree::Core::Engine.root.to_s
35
+ index = callsites.index { |line| !line.start_with? core_root }
36
+
37
+ Spree::Deprecation.warn(
38
+ "Please do not cherry-pick factories, this is not well supported by FactoryBot, " \
39
+ 'follow the changelog instructions on how to migrate your current setup.',
40
+ callsites[index..-1]
41
+ )
42
+ end
43
+
44
+ def self.check_version
45
+ require "factory_bot/version"
46
+
47
+ requirement = Gem::Requirement.new("~> 4.8")
48
+ version = Gem::Version.new(::FactoryBot::VERSION)
49
+
50
+ unless requirement.satisfied_by? version
51
+ Spree::Deprecation.warn(
52
+ "Please be aware that the supported version of FactoryBot is #{requirement}, " \
53
+ "using version #{version} could lead to factory loading issues.", caller(2)
54
+ )
55
+ end
56
+ end
57
+
58
+ def self.add_definitions!
59
+ ::FactoryBot.definition_file_paths.unshift(*definition_file_paths).uniq!
60
+ end
61
+
62
+ def self.add_paths_and_load!
63
+ add_definitions!
64
+ ::FactoryBot.reload
65
+ end
66
+ end
67
+ end
68
+ end
@@ -9,14 +9,14 @@ module Spree
9
9
 
10
10
  def up_to(state)
11
11
  # Need to create a valid zone too...
12
- @zone = FactoryBot.create(:zone)
13
- @country = FactoryBot.create(:country)
14
- @state = FactoryBot.create(:state, country: @country)
12
+ @zone = ::FactoryBot.create(:zone)
13
+ @country = ::FactoryBot.create(:country)
14
+ @state = ::FactoryBot.create(:state, country: @country)
15
15
 
16
16
  @zone.members << Spree::ZoneMember.create(zoneable: @country)
17
17
 
18
18
  # A shipping method must exist for rates to be displayed on checkout page
19
- FactoryBot.create(:shipping_method, zones: [@zone]).tap do |sm|
19
+ ::FactoryBot.create(:shipping_method, zones: [@zone]).tap do |sm|
20
20
  sm.calculator.preferred_amount = 10
21
21
  sm.calculator.preferred_currency = Spree::Config[:currency]
22
22
  sm.calculator.save
@@ -24,7 +24,7 @@ module Spree
24
24
 
25
25
  order = Spree::Order.create!(
26
26
  email: "solidus@example.com",
27
- store: Spree::Store.first || FactoryBot.create(:store)
27
+ store: Spree::Store.first || ::FactoryBot.create(:store)
28
28
  )
29
29
  add_line_item!(order)
30
30
  order.next!
@@ -46,13 +46,13 @@ module Spree
46
46
  private
47
47
 
48
48
  def add_line_item!(order)
49
- FactoryBot.create(:line_item, order: order)
49
+ ::FactoryBot.create(:line_item, order: order)
50
50
  order.reload
51
51
  end
52
52
 
53
53
  def address(order)
54
- order.bill_address = FactoryBot.create(:address, country: @country, state: @state)
55
- order.ship_address = FactoryBot.create(:address, country: @country, state: @state)
54
+ order.bill_address = ::FactoryBot.create(:address, country: @country, state: @state)
55
+ order.ship_address = ::FactoryBot.create(:address, country: @country, state: @state)
56
56
  order.next!
57
57
  end
58
58
 
@@ -61,7 +61,7 @@ module Spree
61
61
  end
62
62
 
63
63
  def payment(order)
64
- credit_card = FactoryBot.create(:credit_card)
64
+ credit_card = ::FactoryBot.create(:credit_card)
65
65
  order.payments.create!(payment_method: credit_card.payment_method, amount: order.total, source: credit_card)
66
66
  # TODO: maybe look at some way of making this payment_state change automatic
67
67
  order.payment_state = 'paid'