Merge pull request #6486 from openfoodfoundation/dependabot/bundler/factory_bot_rails-5.2.0

Bump factory_bot_rails from 4.10.0 to 5.2.0
This commit is contained in:
Andy Brett
2020-12-12 08:58:53 -08:00
committed by GitHub
33 changed files with 165 additions and 163 deletions

View File

@@ -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'

View File

@@ -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)
@@ -756,7 +756,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

View File

@@ -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,15 +70,15 @@ 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
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] }
@@ -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

View File

@@ -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|
@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 '<p>Hello, world!</p><p>This is a paragraph.</p>'
sells { 'any' }
description { 'enterprise' }
long_description { '<p>Hello, world!</p><p>This is a paragraph.</p>' }
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|

View File

@@ -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

View File

@@ -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,8 +10,8 @@ FactoryBot.define do
factory :line_item_with_shipment, parent: :line_item do
transient do
shipping_fee 3
shipping_method nil
shipping_fee { 3 }
shipping_method { nil }
end
after(:build) do |line_item, evaluator|

View File

@@ -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)

View File

@@ -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|
@@ -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

View File

@@ -8,7 +8,7 @@ FactoryBot.define do
user
bill_address
completed_at nil
completed_at { nil }
email { user.email }
factory :order_with_totals do
@@ -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|
@@ -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) }

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
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,9 +67,9 @@ FactoryBot.define do
factory :taxed_product, parent: :product do
transient do
tax_rate_amount 0
tax_rate_name ""
zone nil
tax_rate_amount { 0 }
tax_rate_name { "" }
zone { nil }
end
tax_category { create(:tax_category) }

View File

@@ -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

View File

@@ -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

View File

@@ -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) }

View File

@@ -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) }

View File

@@ -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

View File

@@ -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) }

View File

@@ -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|

View File

@@ -2,7 +2,7 @@
FactoryBot.define do
factory :stock_movement, class: Spree::StockMovement do
quantity 1
action 'sold'
quantity { 1 }
action { 'sold' }
end
end

View File

@@ -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

View File

@@ -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

View File

@@ -2,8 +2,8 @@
FactoryBot.define do
factory :taxon, class: Spree::Taxon do
name 'Ruby on Rails'
name { 'Ruby on Rails' }
taxonomy
parent_id nil
parent_id { nil }
end
end

View File

@@ -2,6 +2,6 @@
FactoryBot.define do
factory :taxonomy, class: Spree::Taxonomy do
name 'Brand'
name { 'Brand' }
end
end

View File

@@ -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

View File

@@ -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

View File

@@ -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'))

View File

@@ -238,3 +238,5 @@ RSpec.configure do |config|
# end
config.infer_spec_type_from_file_location!
end
FactoryBot.use_parent_strategy = false