diff --git a/spec/factories/adjustment_factory.rb b/spec/factories/adjustment_factory.rb index 7c79429052..239d92d6c0 100644 --- a/spec/factories/adjustment_factory.rb +++ b/spec/factories/adjustment_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :adjustment, class: Spree::Adjustment do association(:adjustable, factory: :order) diff --git a/spec/factories/country_factory.rb b/spec/factories/country_factory.rb index 3ea69913ba..c3cd8e2e46 100644 --- a/spec/factories/country_factory.rb +++ b/spec/factories/country_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :country, class: Spree::Country do iso_name 'UNITED STATES' diff --git a/spec/factories/credit_card_factory.rb b/spec/factories/credit_card_factory.rb index 3df2d1f080..27976a55c6 100644 --- a/spec/factories/credit_card_factory.rb +++ b/spec/factories/credit_card_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # allows credit card info to be saved to the database which is needed for factories to work properly class TestCard < Spree::CreditCard def remove_readonly_attributes(attributes) attributes; end @@ -7,7 +9,7 @@ FactoryBot.define do factory :credit_card, class: TestCard do verification_value 123 month 12 - year { Time.now.year + 1 } + year { Time.zone.now.year + 1 } number '4111111111111111' cc_type 'visa' diff --git a/spec/factories/inventory_unit_factory.rb b/spec/factories/inventory_unit_factory.rb index 1bcf71d7d0..47c0bd2aae 100644 --- a/spec/factories/inventory_unit_factory.rb +++ b/spec/factories/inventory_unit_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :inventory_unit, class: Spree::InventoryUnit do variant diff --git a/spec/factories/line_item_factory.rb b/spec/factories/line_item_factory.rb index 25b525555c..f6de86257b 100644 --- a/spec/factories/line_item_factory.rb +++ b/spec/factories/line_item_factory.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + FactoryBot.define do factory :line_item, class: Spree::LineItem do quantity 1 - price { BigDecimal.new('10.00') } + price { BigDecimal('10.00') } order variant end diff --git a/spec/factories/options_factory.rb b/spec/factories/options_factory.rb index be425474b7..1d5b24f2b7 100644 --- a/spec/factories/options_factory.rb +++ b/spec/factories/options_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :option_value, class: Spree::OptionValue do name 'Size' diff --git a/spec/factories/order_factory.rb b/spec/factories/order_factory.rb index 05dc2bddea..fde8605c1c 100644 --- a/spec/factories/order_factory.rb +++ b/spec/factories/order_factory.rb @@ -35,13 +35,11 @@ FactoryBot.define do factory :completed_order_with_totals do state 'complete' - completed_at { Time.now } + completed_at { Time.zone.now } distributor { create(:distributor_enterprise) } - after(:create) do |order| - order.refresh_shipment_rates - end + after(:create, &:refresh_shipment_rates) factory :order_ready_to_ship do payment_state 'paid' @@ -95,7 +93,7 @@ FactoryBot.define do while !order.completed? do break unless a = order.next! end order.select_shipping_method(evaluator.shipping_method.id) end - end + end end factory :order_with_totals_and_distribution, parent: :order_with_distributor do diff --git a/spec/factories/payment_factory.rb b/spec/factories/payment_factory.rb index 40d02a8654..3858b8e913 100644 --- a/spec/factories/payment_factory.rb +++ b/spec/factories/payment_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :payment, class: Spree::Payment do transient do diff --git a/spec/factories/payment_method_factory.rb b/spec/factories/payment_method_factory.rb index b75a5037b3..2eb5a674d3 100644 --- a/spec/factories/payment_method_factory.rb +++ b/spec/factories/payment_method_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :payment_method, class: Spree::PaymentMethod::Check do name 'Check' diff --git a/spec/factories/product_option_type_factory.rb b/spec/factories/product_option_type_factory.rb index 2b6e52b644..22a8b6f96a 100644 --- a/spec/factories/product_option_type_factory.rb +++ b/spec/factories/product_option_type_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :product_option_type, class: Spree::ProductOptionType do product diff --git a/spec/factories/product_property_factory.rb b/spec/factories/product_property_factory.rb index 9844faea47..7db00a14ff 100644 --- a/spec/factories/product_property_factory.rb +++ b/spec/factories/product_property_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :product_property, class: Spree::ProductProperty do product diff --git a/spec/factories/property_factory.rb b/spec/factories/property_factory.rb index 552c6f9738..6cf7ee09b9 100644 --- a/spec/factories/property_factory.rb +++ b/spec/factories/property_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :property, class: Spree::Property do name 'baseball_cap_color' diff --git a/spec/factories/shipment_factory.rb b/spec/factories/shipment_factory.rb index 17d465ced1..ef167d5837 100644 --- a/spec/factories/shipment_factory.rb +++ b/spec/factories/shipment_factory.rb @@ -11,7 +11,7 @@ FactoryBot.define do address stock_location { Spree::StockLocation.first || create(:stock_location) } - after(:create) do |shipment, evalulator| + after(:create) do |shipment, _evalulator| shipment.add_shipping_method(create(:shipping_method), true) shipment.order.line_items.each do |line_item| diff --git a/spec/factories/shipping_category_factory.rb b/spec/factories/shipping_category_factory.rb index 76bebeb25a..9749d3a719 100644 --- a/spec/factories/shipping_category_factory.rb +++ b/spec/factories/shipping_category_factory.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + FactoryBot.define do - factory :shipping_category, class: Spree::ShippingCategory do + factory :shipping_category, class: Spree::ShippingCategory do initialize_with { DefaultShippingCategory.find_or_create } end end diff --git a/spec/factories/shipping_method_factory.rb b/spec/factories/shipping_method_factory.rb index c6ecb67531..aae807d226 100644 --- a/spec/factories/shipping_method_factory.rb +++ b/spec/factories/shipping_method_factory.rb @@ -6,7 +6,7 @@ FactoryBot.define do distributors { [Enterprise.is_distributor.first || FactoryBot.create(:distributor_enterprise)] } display_on '' - before(:create) do |shipping_method, evaluator| + before(:create) do |shipping_method, _evaluator| shipping_method.shipping_categories << DefaultShippingCategory.find_or_create end diff --git a/spec/factories/stock_factory.rb b/spec/factories/stock_factory.rb index 9cb4b2a2eb..b501401507 100644 --- a/spec/factories/stock_factory.rb +++ b/spec/factories/stock_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :stock_package, class: Spree::Stock::Package do ignore do diff --git a/spec/factories/stock_location_factory.rb b/spec/factories/stock_location_factory.rb index 393baa1e7b..48fc14d772 100644 --- a/spec/factories/stock_location_factory.rb +++ b/spec/factories/stock_location_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :stock_location, class: Spree::StockLocation do # keeps the test stock_location unique @@ -14,7 +16,7 @@ FactoryBot.define do country { |stock_location| Spree::Country.first || stock_location.association(:country) } state do |stock_location| - stock_location.country.states.first || stock_location.association(:state, :country => stock_location.country) + stock_location.country.states.first || stock_location.association(:state, country: stock_location.country) end end end diff --git a/spec/factories/tax_category_factory.rb b/spec/factories/tax_category_factory.rb index 6419bb9574..0cb0f3af4a 100644 --- a/spec/factories/tax_category_factory.rb +++ b/spec/factories/tax_category_factory.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + FactoryBot.define do factory :tax_category, class: Spree::TaxCategory do - name { "TaxCategory - #{rand(999999)}" } + name { "TaxCategory - #{rand(999_999)}" } description { generate(:random_string) } end end diff --git a/spec/factories/tax_rate_factory.rb b/spec/factories/tax_rate_factory.rb index 1d1977074f..ae1168ee3f 100644 --- a/spec/factories/tax_rate_factory.rb +++ b/spec/factories/tax_rate_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :tax_rate, class: Spree::TaxRate do zone diff --git a/spec/factories/taxon_factory.rb b/spec/factories/taxon_factory.rb index 47e3699b10..e02e87a9e9 100644 --- a/spec/factories/taxon_factory.rb +++ b/spec/factories/taxon_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :taxon, class: Spree::Taxon do name 'Ruby on Rails' diff --git a/spec/factories/taxonomy_factory.rb b/spec/factories/taxonomy_factory.rb index dc4bfe4855..89d6d317fe 100644 --- a/spec/factories/taxonomy_factory.rb +++ b/spec/factories/taxonomy_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :taxonomy, class: Spree::Taxonomy do name 'Brand' diff --git a/spec/factories/user_factory.rb b/spec/factories/user_factory.rb index ef5a991461..3896b7812c 100644 --- a/spec/factories/user_factory.rb +++ b/spec/factories/user_factory.rb @@ -31,14 +31,14 @@ FactoryBot.define do user.spree_roles.clear # Remove admin role user.enterprises << proxy.enterprises - end + end factory :admin_user do spree_roles { [Spree::Role.find_or_create_by!(name: 'admin')] } after(:create) do |user| user.spree_roles << Spree::Role.find_or_create_by!(name: 'admin') - end + end end end end diff --git a/spec/factories/variant_factory.rb b/spec/factories/variant_factory.rb index 8000e2c6dd..5d477a5603 100644 --- a/spec/factories/variant_factory.rb +++ b/spec/factories/variant_factory.rb @@ -1,5 +1,5 @@ FactoryBot.define do - sequence(:random_float) { BigDecimal.new("#{rand(200)}.#{rand(99)}") } + sequence(:random_float) { BigDecimal("#{rand(200)}.#{rand(99)}") } factory :base_variant, class: Spree::Variant do price 19.99 diff --git a/spec/factories/zone_factory.rb b/spec/factories/zone_factory.rb index 9496ebb8a3..1993f3c913 100644 --- a/spec/factories/zone_factory.rb +++ b/spec/factories/zone_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :zone, class: Spree::Zone do name { generate(:random_string) }