Run rubocop -a on spec/factories

This commit is contained in:
Luis Ramos
2020-08-26 22:18:40 +01:00
parent f9aac02e13
commit 94d1d5f3ae
24 changed files with 51 additions and 15 deletions

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
FactoryBot.define do
factory :adjustment, class: Spree::Adjustment do
association(:adjustable, factory: :order)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
FactoryBot.define do
factory :country, class: Spree::Country do
iso_name 'UNITED STATES'

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
FactoryBot.define do
factory :inventory_unit, class: Spree::InventoryUnit do
variant

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
FactoryBot.define do
factory :option_value, class: Spree::OptionValue do
name 'Size'

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
FactoryBot.define do
factory :payment, class: Spree::Payment do
transient do

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
FactoryBot.define do
factory :payment_method, class: Spree::PaymentMethod::Check do
name 'Check'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
FactoryBot.define do
factory :product_option_type, class: Spree::ProductOptionType do
product

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
FactoryBot.define do
factory :product_property, class: Spree::ProductProperty do
product

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
FactoryBot.define do
factory :property, class: Spree::Property do
name 'baseball_cap_color'

View File

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

View File

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

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
FactoryBot.define do
factory :stock_package, class: Spree::Stock::Package do
ignore do

View File

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

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
FactoryBot.define do
factory :tax_rate, class: Spree::TaxRate do
zone

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
FactoryBot.define do
factory :taxon, class: Spree::Taxon do
name 'Ruby on Rails'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
FactoryBot.define do
factory :taxonomy, class: Spree::Taxonomy do
name 'Brand'

View File

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

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
FactoryBot.define do
factory :zone, class: Spree::Zone do
name { generate(:random_string) }