mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-08 07:46:59 +00:00
Run rubocop -a on spec/factories
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :adjustment, class: Spree::Adjustment do
|
||||
association(:adjustable, factory: :order)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :country, class: Spree::Country do
|
||||
iso_name 'UNITED STATES'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :inventory_unit, class: Spree::InventoryUnit do
|
||||
variant
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :option_value, class: Spree::OptionValue do
|
||||
name 'Size'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :payment, class: Spree::Payment do
|
||||
transient do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :payment_method, class: Spree::PaymentMethod::Check do
|
||||
name 'Check'
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :product_option_type, class: Spree::ProductOptionType do
|
||||
product
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :product_property, class: Spree::ProductProperty do
|
||||
product
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :property, class: Spree::Property do
|
||||
name 'baseball_cap_color'
|
||||
|
||||
@@ -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|
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :stock_package, class: Spree::Stock::Package do
|
||||
ignore do
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :tax_rate, class: Spree::TaxRate do
|
||||
zone
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :taxon, class: Spree::Taxon do
|
||||
name 'Ruby on Rails'
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :taxonomy, class: Spree::Taxonomy do
|
||||
name 'Brand'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :zone, class: Spree::Zone do
|
||||
name { generate(:random_string) }
|
||||
|
||||
Reference in New Issue
Block a user