From 5c65f9bf55c71d5e32e0c0575e4aa96bdf52d3f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Dec 2020 20:24:41 +0000 Subject: [PATCH 1/6] Bump factory_bot_rails from 4.10.0 to 5.2.0 Bumps [factory_bot_rails](https://github.com/thoughtbot/factory_bot_rails) from 4.10.0 to 5.2.0. - [Release notes](https://github.com/thoughtbot/factory_bot_rails/releases) - [Changelog](https://github.com/thoughtbot/factory_bot_rails/blob/master/NEWS.md) - [Commits](https://github.com/thoughtbot/factory_bot_rails/compare/v4.10.0...v5.2.0) Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index 25b549f0ab..6e6c38a4db 100644 --- a/Gemfile +++ b/Gemfile @@ -128,7 +128,7 @@ group :test, :development do gem 'awesome_print' gem 'capybara', '>= 2.18.0' # 3.0 requires rack 1.6 that only works with Rails 4.2 gem 'database_cleaner', require: false - gem "factory_bot_rails", '4.10.0', require: false + gem "factory_bot_rails", '5.2.0', require: false gem 'fuubar', '~> 2.5.0' gem 'json_spec', '~> 1.1.4' gem 'knapsack' diff --git a/Gemfile.lock b/Gemfile.lock index 1f8af10df8..d645b6c160 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -215,11 +215,11 @@ GEM eventmachine (1.2.7) excon (0.78.0) execjs (2.7.0) - factory_bot (4.10.0) - activesupport (>= 3.0.0) - factory_bot_rails (4.10.0) - factory_bot (~> 4.10.0) - railties (>= 3.0.0) + factory_bot (5.2.0) + activesupport (>= 4.2.0) + factory_bot_rails (5.2.0) + factory_bot (~> 5.2.0) + railties (>= 4.2.0) faraday (1.0.1) multipart-post (>= 1.2, < 3) ffaker (2.11.0) @@ -757,7 +757,7 @@ DEPENDENCIES devise-token_authenticatable dfc_provider! eventmachine (>= 1.2.3) - factory_bot_rails (= 4.10.0) + factory_bot_rails (= 5.2.0) ffaker figaro foundation-icons-sass-rails From c17998774e9dadee8f1ddcdda8360835b0c921d7 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Wed, 9 Dec 2020 23:09:33 +0000 Subject: [PATCH 2/6] Adapt factories to factory_bot_rails v5 syntax --- spec/factories.rb | 44 +++++++++---------- spec/factories/address_factory.rb | 18 ++++---- spec/factories/adjustment_factory.rb | 6 +-- spec/factories/country_factory.rb | 10 ++--- spec/factories/credit_card_factory.rb | 12 ++--- spec/factories/enterprise_factory.rb | 18 ++++---- spec/factories/inventory_unit_factory.rb | 2 +- spec/factories/line_item_factory.rb | 4 +- spec/factories/options_factory.rb | 8 ++-- spec/factories/order_cycle_factory.rb | 6 +-- spec/factories/order_factory.rb | 18 ++++---- spec/factories/payment_factory.rb | 8 ++-- spec/factories/payment_method_factory.rb | 20 ++++----- spec/factories/price_factory.rb | 4 +- spec/factories/product_factory.rb | 20 ++++----- spec/factories/property_factory.rb | 4 +- .../factories/return_authorization_factory.rb | 8 ++-- spec/factories/shipment_factory.rb | 16 +++---- spec/factories/shipping_method_factory.rb | 10 ++--- spec/factories/state_factory.rb | 4 +- spec/factories/stock_location_factory.rb | 12 ++--- spec/factories/stock_movement_factory.rb | 4 +- spec/factories/subscription_factory.rb | 6 +-- spec/factories/tax_rate_factory.rb | 2 +- spec/factories/taxon_factory.rb | 2 +- spec/factories/taxonomy_factory.rb | 2 +- spec/factories/user_factory.rb | 8 ++-- spec/factories/variant_factory.rb | 8 ++-- spec/factories/zone_factory.rb | 2 +- 29 files changed, 143 insertions(+), 143 deletions(-) diff --git a/spec/factories.rb b/spec/factories.rb index 73cbb38348..1e1298220c 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -11,7 +11,7 @@ FactoryBot.define do end factory :exchange, class: Exchange do - incoming false + incoming { false } order_cycle { OrderCycle.first || FactoryBot.create(:simple_order_cycle) } sender { incoming ? FactoryBot.create(:enterprise) : order_cycle.coordinator } receiver { incoming ? order_cycle.coordinator : FactoryBot.create(:enterprise) } @@ -40,27 +40,27 @@ FactoryBot.define do end factory :variant_override, class: VariantOverride do - price 77.77 - on_demand false - count_on_hand 11_111 - default_stock 2000 - resettable false + price { 77.77 } + on_demand { false } + count_on_hand { 11_111 } + default_stock { 2000 } + resettable { false } trait :on_demand do - on_demand true - count_on_hand nil + on_demand { true } + count_on_hand { nil } end trait :use_producer_stock_settings do - on_demand nil - count_on_hand nil + on_demand { nil } + count_on_hand { nil } end end factory :inventory_item, class: InventoryItem do enterprise variant - visible true + visible { true } end factory :enterprise_relationship do @@ -70,10 +70,10 @@ FactoryBot.define do end factory :enterprise_group, class: EnterpriseGroup do - name 'Enterprise group' + name { 'Enterprise group' } sequence(:permalink) { |n| "group#{n}" } - description 'this is a group' - on_front_page false + description { 'this is a group' } + on_front_page { false } address { FactoryBot.build(:address) } end @@ -89,12 +89,12 @@ FactoryBot.define do after(:create) { |ef| ef.calculator.save! } trait :flat_rate do - transient { amount 1 } + transient { amount { 1 } } calculator { build(:calculator_flat_rate, preferred_amount: amount) } end trait :per_item do - transient { amount 1 } + transient { amount { 1 } } calculator { build(:calculator_per_item, preferred_amount: amount) } end end @@ -102,13 +102,13 @@ FactoryBot.define do factory :adjustment_metadata, class: AdjustmentMetadata do adjustment { FactoryBot.create(:adjustment) } enterprise { FactoryBot.create(:distributor_enterprise) } - fee_name 'fee' - fee_type 'packing' - enterprise_role 'distributor' + fee_name { 'fee' } + fee_type { 'packing' } + enterprise_role { 'distributor' } end factory :producer_property, class: ProducerProperty do - value 'abc123' + value { 'abc123' } producer { create(:supplier_enterprise) } property end @@ -123,7 +123,7 @@ FactoryBot.define do factory :stripe_account do enterprise { FactoryBot.create(:distributor_enterprise) } - stripe_user_id "abc123" - stripe_publishable_key "xyz456" + stripe_user_id { "abc123" } + stripe_publishable_key { "xyz456" } end end diff --git a/spec/factories/address_factory.rb b/spec/factories/address_factory.rb index 9ab43be4bf..b2f00e7059 100644 --- a/spec/factories/address_factory.rb +++ b/spec/factories/address_factory.rb @@ -2,15 +2,15 @@ FactoryBot.define do factory :address, aliases: [:bill_address, :ship_address], class: Spree::Address do - firstname 'John' - lastname 'Doe' - company 'Company' - address1 '10 Lovely Street' - address2 'Northwest' - city 'Herndon' - zipcode '20170' - phone '123-456-7890' - alternative_phone '123-456-7899' + firstname { 'John' } + lastname { 'Doe' } + company { 'Company' } + address1 { '10 Lovely Street' } + address2 { 'Northwest' } + city { 'Herndon' } + zipcode { '20170' } + phone { '123-456-7890' } + alternative_phone { '123-456-7899' } state { Spree::State.find_by(name: 'Victoria') || Spree::State.first || create(:state) } country do |address| diff --git a/spec/factories/adjustment_factory.rb b/spec/factories/adjustment_factory.rb index 239d92d6c0..96360610b3 100644 --- a/spec/factories/adjustment_factory.rb +++ b/spec/factories/adjustment_factory.rb @@ -3,9 +3,9 @@ FactoryBot.define do factory :adjustment, class: Spree::Adjustment do association(:adjustable, factory: :order) - amount 100.0 - label 'Shipping' + amount { 100.0 } + label { 'Shipping' } association(:source, factory: :shipment) - eligible true + eligible { true } end end diff --git a/spec/factories/country_factory.rb b/spec/factories/country_factory.rb index c3cd8e2e46..6a05f63e58 100644 --- a/spec/factories/country_factory.rb +++ b/spec/factories/country_factory.rb @@ -2,10 +2,10 @@ FactoryBot.define do factory :country, class: Spree::Country do - iso_name 'UNITED STATES' - name 'United States of America' - iso 'US' - iso3 'USA' - numcode 840 + iso_name { 'UNITED STATES' } + name { 'United States of America' } + iso { 'US' } + iso3 { 'USA' } + numcode { 840 } end end diff --git a/spec/factories/credit_card_factory.rb b/spec/factories/credit_card_factory.rb index 27976a55c6..9b411a8f5e 100644 --- a/spec/factories/credit_card_factory.rb +++ b/spec/factories/credit_card_factory.rb @@ -7,17 +7,17 @@ end FactoryBot.define do factory :credit_card, class: TestCard do - verification_value 123 - month 12 + verification_value { 123 } + month { 12 } year { Time.zone.now.year + 1 } - number '4111111111111111' + number { '4111111111111111' } - cc_type 'visa' + cc_type { 'visa' } end # A card that has been added to the user's profile and can be re-used. factory :stored_credit_card, parent: :credit_card do - gateway_customer_profile_id "cus_F2T..." - gateway_payment_profile_id "card_1EY..." + gateway_customer_profile_id { "cus_F2T..." } + gateway_payment_profile_id { "card_1EY..." } end end diff --git a/spec/factories/enterprise_factory.rb b/spec/factories/enterprise_factory.rb index dce7d218e8..48d87ccdcd 100644 --- a/spec/factories/enterprise_factory.rb +++ b/spec/factories/enterprise_factory.rb @@ -3,16 +3,16 @@ FactoryBot.define do factory :enterprise, class: Enterprise do transient do - users [] + users { [] } logo {} promo_image {} end owner factory: :user sequence(:name) { |n| "Enterprise #{n}" } - sells 'any' - description 'enterprise' - long_description '

Hello, world!

This is a paragraph.

' + sells { 'any' } + description { 'enterprise' } + long_description { '

Hello, world!

This is a paragraph.

' } address after(:create) do |enterprise, proxy| @@ -24,16 +24,16 @@ FactoryBot.define do end factory :supplier_enterprise, parent: :enterprise do - is_primary_producer true - sells "none" + is_primary_producer { true } + sells { "none" } end factory :distributor_enterprise, parent: :enterprise do - is_primary_producer false - sells "any" + is_primary_producer { false } + sells { "any" } transient do - with_payment_and_shipping false + with_payment_and_shipping { false } end after(:create) do |enterprise, proxy| diff --git a/spec/factories/inventory_unit_factory.rb b/spec/factories/inventory_unit_factory.rb index 47c0bd2aae..29df105a66 100644 --- a/spec/factories/inventory_unit_factory.rb +++ b/spec/factories/inventory_unit_factory.rb @@ -4,7 +4,7 @@ FactoryBot.define do factory :inventory_unit, class: Spree::InventoryUnit do variant order - state 'on_hand' + state { 'on_hand' } association(:shipment, factory: :shipment, state: 'pending') end end diff --git a/spec/factories/line_item_factory.rb b/spec/factories/line_item_factory.rb index f6de86257b..27400f89eb 100644 --- a/spec/factories/line_item_factory.rb +++ b/spec/factories/line_item_factory.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :line_item, class: Spree::LineItem do - quantity 1 + quantity { 1 } price { BigDecimal('10.00') } order variant @@ -10,7 +10,7 @@ FactoryBot.define do factory :line_item_with_shipment, parent: :line_item do transient do - shipping_fee 3 + shipping_fee { 3 } shipping_method nil end diff --git a/spec/factories/options_factory.rb b/spec/factories/options_factory.rb index 1d5b24f2b7..772c4f8320 100644 --- a/spec/factories/options_factory.rb +++ b/spec/factories/options_factory.rb @@ -2,14 +2,14 @@ FactoryBot.define do factory :option_value, class: Spree::OptionValue do - name 'Size' - presentation 'S' + name { 'Size' } + presentation { 'S' } option_type end factory :option_type, class: Spree::OptionType do - name 'foo-size' - presentation 'Size' + name { 'foo-size' } + presentation { 'Size' } # Prevent inconsistent ordering in specs when all option types have the same (0) position sequence(:position) diff --git a/spec/factories/order_cycle_factory.rb b/spec/factories/order_cycle_factory.rb index 20018a175e..4360a83be0 100644 --- a/spec/factories/order_cycle_factory.rb +++ b/spec/factories/order_cycle_factory.rb @@ -78,9 +78,9 @@ FactoryBot.define do coordinator { Enterprise.is_distributor.first || FactoryBot.create(:distributor_enterprise) } transient do - suppliers [] - distributors [] - variants [] + suppliers { [] } + distributors { [] } + variants { [] } end after(:create) do |oc, proxy| diff --git a/spec/factories/order_factory.rb b/spec/factories/order_factory.rb index c17a9d8427..c2447303a7 100644 --- a/spec/factories/order_factory.rb +++ b/spec/factories/order_factory.rb @@ -36,7 +36,7 @@ FactoryBot.define do end factory :completed_order_with_totals do - state 'complete' + state { 'complete' } completed_at { Time.zone.now } distributor { create(:distributor_enterprise) } @@ -44,8 +44,8 @@ FactoryBot.define do after(:create, &:refresh_shipment_rates) factory :order_ready_to_ship do - payment_state 'paid' - shipment_state 'ready' + payment_state { 'paid' } + shipment_state { 'ready' } after(:create) do |order| create(:payment, amount: order.total, order: order, state: 'completed') order.shipments.each do |shipment| @@ -100,7 +100,7 @@ FactoryBot.define do factory :order_with_totals_and_distribution, parent: :order_with_distributor do transient do - shipping_fee 3 + shipping_fee { 3 } end order_cycle { create(:simple_order_cycle) } @@ -120,9 +120,9 @@ FactoryBot.define do factory :order_with_taxes, parent: :completed_order_with_totals do transient do - product_price 0 - tax_rate_amount 0 - tax_rate_name "" + product_price { 0 } + tax_rate_amount { 0 } + tax_rate_name { "" } zone { create(:zone_with_member) } end @@ -170,8 +170,8 @@ FactoryBot.define do factory :completed_order_with_fees, parent: :order_with_distributor do transient do - payment_fee 5 - shipping_fee 3 + payment_fee { 5 } + shipping_fee { 3 } end ship_address { create(:address) } diff --git a/spec/factories/payment_factory.rb b/spec/factories/payment_factory.rb index 3858b8e913..96b71bd0e4 100644 --- a/spec/factories/payment_factory.rb +++ b/spec/factories/payment_factory.rb @@ -10,17 +10,17 @@ FactoryBot.define do } end - amount 45.75 + amount { 45.75 } association(:source, factory: :credit_card) order - state 'checkout' - response_code '12345' + state { 'checkout' } + response_code { '12345' } payment_method { FactoryBot.create(:payment_method, distributors: [distributor]) } end factory :check_payment, class: Spree::Payment do - amount 45.75 + amount { 45.75 } payment_method order end diff --git a/spec/factories/payment_method_factory.rb b/spec/factories/payment_method_factory.rb index 254c684018..0e796b050a 100644 --- a/spec/factories/payment_method_factory.rb +++ b/spec/factories/payment_method_factory.rb @@ -2,37 +2,37 @@ FactoryBot.define do factory :payment_method, class: Spree::PaymentMethod::Check do - name 'Check' - environment 'test' + name { 'Check' } + environment { 'test' } distributors { [Enterprise.is_distributor.first || FactoryBot.create(:distributor_enterprise)] } trait :flat_rate do - transient { amount 1 } + transient { amount { 1 } } calculator { build(:calculator_flat_rate, preferred_amount: amount) } end trait :per_item do - transient { amount 1 } + transient { amount { 1 } } calculator { build(:calculator_per_item, preferred_amount: amount) } end end factory :bogus_payment_method, class: Spree::Gateway::Bogus do - name 'Credit Card' - environment 'test' + name { 'Credit Card' } + environment { 'test' } end factory :stripe_connect_payment_method, class: Spree::Gateway::StripeConnect do - name 'StripeConnect' - environment 'test' + name { 'StripeConnect' } + environment { 'test' } distributors { [FactoryBot.create(:enterprise)] } preferred_enterprise_id { distributors.first.id } end factory :stripe_sca_payment_method, class: Spree::Gateway::StripeSCA do - name 'StripeSCA' - environment 'test' + name { 'StripeSCA' } + environment { 'test' } distributors { [FactoryBot.create(:stripe_account).enterprise] } preferred_enterprise_id { distributors.first.id } end diff --git a/spec/factories/price_factory.rb b/spec/factories/price_factory.rb index ccb8b886b3..e631200833 100644 --- a/spec/factories/price_factory.rb +++ b/spec/factories/price_factory.rb @@ -3,7 +3,7 @@ FactoryBot.define do factory :price, class: Spree::Price do variant - amount 19.99 - currency 'USD' + amount { 19.99 } + currency { 'USD' } end end diff --git a/spec/factories/product_factory.rb b/spec/factories/product_factory.rb index 3fd1df2527..37ef46e5a8 100644 --- a/spec/factories/product_factory.rb +++ b/spec/factories/product_factory.rb @@ -4,21 +4,21 @@ FactoryBot.define do factory :base_product, class: Spree::Product do sequence(:name) { |n| "Product ##{n} - #{Kernel.rand(9999)}" } description { generate(:random_description) } - price 19.99 - cost_price 17.00 - sku 'ABC' + price { 19.99 } + cost_price { 17.00 } + sku { 'ABC' } available_on { 1.year.ago } deleted_at nil supplier { Enterprise.is_primary_producer.first || FactoryBot.create(:supplier_enterprise) } primary_taxon { Spree::Taxon.first || FactoryBot.create(:taxon) } - unit_value 1 - unit_description '' + unit_value { 1 } + unit_description { '' } - variant_unit 'weight' - variant_unit_scale 1 - variant_unit_name '' + variant_unit { 'weight' } + variant_unit_scale { 1 } + variant_unit_name { '' } shipping_category { DefaultShippingCategory.find_or_create } @@ -67,8 +67,8 @@ FactoryBot.define do factory :taxed_product, parent: :product do transient do - tax_rate_amount 0 - tax_rate_name "" + tax_rate_amount { 0 } + tax_rate_name { "" } zone nil end diff --git a/spec/factories/property_factory.rb b/spec/factories/property_factory.rb index 6cf7ee09b9..39012770ce 100644 --- a/spec/factories/property_factory.rb +++ b/spec/factories/property_factory.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :property, class: Spree::Property do - name 'baseball_cap_color' - presentation 'cap color' + name { 'baseball_cap_color' } + presentation { 'cap color' } end end diff --git a/spec/factories/return_authorization_factory.rb b/spec/factories/return_authorization_factory.rb index 5f3f3245b7..37460d4ac8 100644 --- a/spec/factories/return_authorization_factory.rb +++ b/spec/factories/return_authorization_factory.rb @@ -2,10 +2,10 @@ FactoryBot.define do factory :return_authorization, class: Spree::ReturnAuthorization do - number '100' - amount 100.00 + number { '100' } + amount { 100.00 } association(:order, factory: :shipped_order) - reason 'no particular reason' - state 'received' + reason { 'no particular reason' } + state { 'received' } end end diff --git a/spec/factories/shipment_factory.rb b/spec/factories/shipment_factory.rb index cc062b2740..e923886b8b 100644 --- a/spec/factories/shipment_factory.rb +++ b/spec/factories/shipment_factory.rb @@ -5,10 +5,10 @@ FactoryBot.define do # keeps test shipments unique per order initialize_with { Spree::Shipment.find_or_create_by(order_id: order.id) } - tracking 'U10000' - number '100' - cost 100.00 - state 'pending' + tracking { 'U10000' } + number { '100' } + cost { 100.00 } + state { 'pending' } order address stock_location { Spree::StockLocation.first || create(:stock_location) } @@ -23,10 +23,10 @@ FactoryBot.define do end factory :shipment_with, class: Spree::Shipment do - tracking 'U10000' - number '100' - cost 100.00 - state 'pending' + tracking { 'U10000' } + number { '100' } + cost { 100.00 } + state { 'pending' } order address stock_location { Spree::StockLocation.first || create(:stock_location) } diff --git a/spec/factories/shipping_method_factory.rb b/spec/factories/shipping_method_factory.rb index 900830f9d2..d67a20aaf7 100644 --- a/spec/factories/shipping_method_factory.rb +++ b/spec/factories/shipping_method_factory.rb @@ -3,22 +3,22 @@ FactoryBot.define do factory :base_shipping_method, class: Spree::ShippingMethod do zones { [] } - name 'UPS Ground' + name { 'UPS Ground' } distributors { [Enterprise.is_distributor.first || FactoryBot.create(:distributor_enterprise)] } - display_on '' + display_on { '' } before(:create) do |shipping_method, _evaluator| shipping_method.shipping_categories << DefaultShippingCategory.find_or_create end trait :flat_rate do - transient { amount 1 } + transient { amount { 1 } } calculator { build(:calculator_flat_rate, preferred_amount: amount) } end trait :per_item do - transient { amount 1 } + transient { amount { 1 } } calculator { build(:calculator_per_item, preferred_amount: amount) } end @@ -59,7 +59,7 @@ FactoryBot.define do trait :shipping_fee do transient do - shipping_fee 3 + shipping_fee { 3 } end calculator { build(:calculator_per_item, preferred_amount: shipping_fee) } diff --git a/spec/factories/state_factory.rb b/spec/factories/state_factory.rb index 6540f90a12..6e8eb57a0e 100644 --- a/spec/factories/state_factory.rb +++ b/spec/factories/state_factory.rb @@ -2,8 +2,8 @@ FactoryBot.define do factory :state, class: Spree::State do - name 'Alabama' - abbr 'AL' + name { 'Alabama' } + abbr { 'AL' } country do |country| if usa = Spree::Country.find_by(numcode: 840) country = usa diff --git a/spec/factories/stock_location_factory.rb b/spec/factories/stock_location_factory.rb index 0193a40281..ac32b2e514 100644 --- a/spec/factories/stock_location_factory.rb +++ b/spec/factories/stock_location_factory.rb @@ -5,14 +5,14 @@ FactoryBot.define do # keeps the test stock_location unique initialize_with { Spree::StockLocation.first || DefaultStockLocation.find_or_create } - address1 '1600 Pennsylvania Ave NW' - city 'Washington' - zipcode '20500' - phone '(202) 456-1111' - active true + address1 { '1600 Pennsylvania Ave NW' } + city { 'Washington' } + zipcode { '20500' } + phone { '(202) 456-1111' } + active { true } # sets the default value for variant.on_demand - backorderable_default false + backorderable_default { false } country { |stock_location| Spree::Country.first || stock_location.association(:country) } state do |stock_location| diff --git a/spec/factories/stock_movement_factory.rb b/spec/factories/stock_movement_factory.rb index 22ffb95a8d..2ca6e3e714 100644 --- a/spec/factories/stock_movement_factory.rb +++ b/spec/factories/stock_movement_factory.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :stock_movement, class: Spree::StockMovement do - quantity 1 - action 'sold' + quantity { 1 } + action { 'sold' } end end diff --git a/spec/factories/subscription_factory.rb b/spec/factories/subscription_factory.rb index 8f288d46a8..f0b67c0631 100644 --- a/spec/factories/subscription_factory.rb +++ b/spec/factories/subscription_factory.rb @@ -12,8 +12,8 @@ FactoryBot.define do begins_at { 1.month.ago } transient do - with_items false - with_proxy_orders false + with_items { false } + with_proxy_orders { false } end after(:create) do |subscription, proxy| @@ -46,6 +46,6 @@ FactoryBot.define do factory :subscription_line_item, class: SubscriptionLineItem do subscription variant - quantity 1 + quantity { 1 } end end diff --git a/spec/factories/tax_rate_factory.rb b/spec/factories/tax_rate_factory.rb index ae1168ee3f..2cb9f6e780 100644 --- a/spec/factories/tax_rate_factory.rb +++ b/spec/factories/tax_rate_factory.rb @@ -3,7 +3,7 @@ FactoryBot.define do factory :tax_rate, class: Spree::TaxRate do zone - amount 100.00 + amount { 100.00 } tax_category end end diff --git a/spec/factories/taxon_factory.rb b/spec/factories/taxon_factory.rb index e02e87a9e9..bc767b111d 100644 --- a/spec/factories/taxon_factory.rb +++ b/spec/factories/taxon_factory.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :taxon, class: Spree::Taxon do - name 'Ruby on Rails' + name { 'Ruby on Rails' } taxonomy parent_id nil end diff --git a/spec/factories/taxonomy_factory.rb b/spec/factories/taxonomy_factory.rb index 89d6d317fe..eafe9f8a61 100644 --- a/spec/factories/taxonomy_factory.rb +++ b/spec/factories/taxonomy_factory.rb @@ -2,6 +2,6 @@ FactoryBot.define do factory :taxonomy, class: Spree::Taxonomy do - name 'Brand' + name { 'Brand' } end end diff --git a/spec/factories/user_factory.rb b/spec/factories/user_factory.rb index 48303eb0bd..7404e56c67 100644 --- a/spec/factories/user_factory.rb +++ b/spec/factories/user_factory.rb @@ -7,17 +7,17 @@ FactoryBot.define do factory :user, class: Spree.user_class do transient do - enterprises [] + enterprises { [] } end email { generate(:random_email) } login { email } - password 'secret' + password { 'secret' } password_confirmation { password } authentication_token { generate(:user_authentication_token) } if Spree.user_class.attribute_method? :authentication_token - confirmation_sent_at '1970-01-01 00:00:00' - confirmed_at '1970-01-01 00:00:01' + confirmation_sent_at { '1970-01-01 00:00:00' } + confirmed_at { '1970-01-01 00:00:01' } before(:create) do |user, evaluator| if evaluator.confirmation_sent_at diff --git a/spec/factories/variant_factory.rb b/spec/factories/variant_factory.rb index 06a4c1f9f8..6fd72c63f0 100644 --- a/spec/factories/variant_factory.rb +++ b/spec/factories/variant_factory.rb @@ -4,8 +4,8 @@ FactoryBot.define do sequence(:random_float) { BigDecimal("#{rand(200)}.#{rand(99)}") } factory :base_variant, class: Spree::Variant do - price 19.99 - cost_price 17.00 + price { 19.99 } + cost_price { 17.00 } sku { SecureRandom.hex } weight { generate(:random_float) } height { generate(:random_float) } @@ -25,8 +25,8 @@ FactoryBot.define do end product { |p| p.association(:product) } - unit_value 1 - unit_description '' + unit_value { 1 } + unit_description { '' } after(:create) do |variant, evaluator| variant.on_demand = evaluator.on_demand diff --git a/spec/factories/zone_factory.rb b/spec/factories/zone_factory.rb index 1993f3c913..9215373e64 100644 --- a/spec/factories/zone_factory.rb +++ b/spec/factories/zone_factory.rb @@ -7,7 +7,7 @@ FactoryBot.define do end factory :zone_with_member, parent: :zone do - default_tax true + default_tax { true } after(:create) do |zone| Spree::ZoneMember.create!(zone: zone, zoneable: Spree::Country.find_by(name: 'Australia')) From 9728b088f91d795e4012db0872530a4e61b5d1bc Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Wed, 9 Dec 2020 23:38:16 +0000 Subject: [PATCH 3/6] Fix syntax for nil properties --- spec/factories/address_factory.rb | 2 +- spec/factories/line_item_factory.rb | 2 +- spec/factories/order_cycle_factory.rb | 4 ++-- spec/factories/order_factory.rb | 2 +- spec/factories/product_factory.rb | 4 ++-- spec/factories/taxon_factory.rb | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/factories/address_factory.rb b/spec/factories/address_factory.rb index b2f00e7059..3a2dadf090 100644 --- a/spec/factories/address_factory.rb +++ b/spec/factories/address_factory.rb @@ -25,7 +25,7 @@ FactoryBot.define do firstname { FFaker::Name.first_name } lastname { FFaker::Name.last_name } address1 { FFaker::Address.street_address } - address2 nil + address2 { nil } phone { FFaker::PhoneNumber.phone_number } end end diff --git a/spec/factories/line_item_factory.rb b/spec/factories/line_item_factory.rb index 27400f89eb..d67dcdf24b 100644 --- a/spec/factories/line_item_factory.rb +++ b/spec/factories/line_item_factory.rb @@ -11,7 +11,7 @@ FactoryBot.define do factory :line_item_with_shipment, parent: :line_item do transient do shipping_fee { 3 } - shipping_method nil + shipping_method { nil } end after(:build) do |line_item, evaluator| diff --git a/spec/factories/order_cycle_factory.rb b/spec/factories/order_cycle_factory.rb index 4360a83be0..a241672f6d 100644 --- a/spec/factories/order_cycle_factory.rb +++ b/spec/factories/order_cycle_factory.rb @@ -106,8 +106,8 @@ FactoryBot.define do end factory :undated_order_cycle, parent: :simple_order_cycle do - orders_open_at nil - orders_close_at nil + orders_open_at { nil } + orders_close_at { nil } end factory :upcoming_order_cycle, parent: :simple_order_cycle do diff --git a/spec/factories/order_factory.rb b/spec/factories/order_factory.rb index c2447303a7..5c769df5a9 100644 --- a/spec/factories/order_factory.rb +++ b/spec/factories/order_factory.rb @@ -8,7 +8,7 @@ FactoryBot.define do user bill_address - completed_at nil + completed_at { nil } email { user.email } factory :order_with_totals do diff --git a/spec/factories/product_factory.rb b/spec/factories/product_factory.rb index 37ef46e5a8..3ea1f39da0 100644 --- a/spec/factories/product_factory.rb +++ b/spec/factories/product_factory.rb @@ -8,7 +8,7 @@ FactoryBot.define do cost_price { 17.00 } sku { 'ABC' } available_on { 1.year.ago } - deleted_at nil + deleted_at { nil } supplier { Enterprise.is_primary_producer.first || FactoryBot.create(:supplier_enterprise) } primary_taxon { Spree::Taxon.first || FactoryBot.create(:taxon) } @@ -69,7 +69,7 @@ FactoryBot.define do transient do tax_rate_amount { 0 } tax_rate_name { "" } - zone nil + zone { nil } end tax_category { create(:tax_category) } diff --git a/spec/factories/taxon_factory.rb b/spec/factories/taxon_factory.rb index bc767b111d..fa8bae12d3 100644 --- a/spec/factories/taxon_factory.rb +++ b/spec/factories/taxon_factory.rb @@ -4,6 +4,6 @@ FactoryBot.define do factory :taxon, class: Spree::Taxon do name { 'Ruby on Rails' } taxonomy - parent_id nil + parent_id { nil } end end From bcf7cc10137bc34e6d9d6652af55bdc05da82afd Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Thu, 10 Dec 2020 22:14:40 +0000 Subject: [PATCH 4/6] Replace ignore with transient according to changes in factory bot v5 --- spec/factories/order_factory.rb | 4 ++-- spec/factories/stock_factory.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/factories/order_factory.rb b/spec/factories/order_factory.rb index 5c769df5a9..04885c0965 100644 --- a/spec/factories/order_factory.rb +++ b/spec/factories/order_factory.rb @@ -22,8 +22,8 @@ FactoryBot.define do bill_address ship_address - ignore do - line_items_count 5 + transient do + line_items_count { 5 } end after(:create) do |order, evaluator| diff --git a/spec/factories/stock_factory.rb b/spec/factories/stock_factory.rb index c288121873..8497ec02f4 100644 --- a/spec/factories/stock_factory.rb +++ b/spec/factories/stock_factory.rb @@ -2,10 +2,10 @@ FactoryBot.define do factory :stock_package, class: OrderManagement::Stock::Package do - ignore do + transient do stock_location { build(:stock_location) } order { create(:order_with_line_items, line_items_count: 2) } - contents [] + contents { [] } end initialize_with { new(stock_location, order, contents) } From 79c538fad9c2d825ab173cbfb3a4e64c1d8293e4 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Thu, 10 Dec 2020 23:44:24 +0000 Subject: [PATCH 5/6] Fix syntax for nil property --- spec/factories.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/factories.rb b/spec/factories.rb index 1e1298220c..f766c0cb19 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -78,7 +78,7 @@ FactoryBot.define do end factory :enterprise_fee, class: EnterpriseFee do - transient { amount nil } + transient { amount { nil } } sequence(:name) { |n| "Enterprise fee #{n}" } sequence(:fee_type) { |n| EnterpriseFee::FEE_TYPES[n % EnterpriseFee::FEE_TYPES.count] } From 1ea775cffb40aa20b7f50f1a61f6dc662fa2794c Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Sat, 12 Dec 2020 00:23:24 +0000 Subject: [PATCH 6/6] Keep factory bot v4 behaviour In v5 the default value is true, that means that all parent objects (for example the order od a line item) will be built using the same strategy as the object (build or create), in v4 and now with this config, the parent is always created We can revert this and use the default value but that will require some adaptions, quite a lot of specs are broken with that behaviour activated --- spec/spec_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c4a2fdbc21..41f3d47bd5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -238,3 +238,5 @@ RSpec.configure do |config| # end config.infer_spec_type_from_file_location! end + +FactoryBot.use_parent_strategy = false