Skip to content

Commit

Permalink
Remove deprecated factories usage
Browse files Browse the repository at this point in the history
Ref #3907
  • Loading branch information
kennyadsl committed Apr 18, 2023
1 parent 04a4d68 commit d64b79f
Show file tree
Hide file tree
Showing 62 changed files with 0 additions and 503 deletions.
20 changes: 0 additions & 20 deletions core/lib/spree/testing_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,7 @@
module Spree
module TestingSupport
autoload :FactoryBot, "spree/testing_support/factory_bot"

autoload :SEQUENCES, "spree/testing_support/factory_bot"
autoload :FACTORIES, "spree/testing_support/factory_bot"

def factory_bot_paths
Spree::TestingSupport::FactoryBot.definition_file_paths
end

def check_factory_bot_version
Spree::TestingSupport::FactoryBot.check_version
end

def load_all_factories
Spree::TestingSupport::FactoryBot.add_paths_and_load!
end

deprecate(
factory_bot_paths: "Spree::TestingSupport::FactoryBot.definition_file_paths",
check_factory_bot_version: "Spree::TestingSupport::FactoryBot.check_version",
load_all_factories: "Spree::TestingSupport::FactoryBot.add_paths_and_load!",
deprecator: Spree::Deprecation
)
end
end
11 changes: 0 additions & 11 deletions core/lib/spree/testing_support/factories.rb

This file was deleted.

7 changes: 0 additions & 7 deletions core/lib/spree/testing_support/factories/address_factory.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/factories/state_factory'
require 'spree/testing_support/factories/country_factory'
end
FactoryBot.define do
factory :address, class: 'Spree::Address' do
transient do
Expand Down
11 changes: 0 additions & 11 deletions core/lib/spree/testing_support/factories/adjustment_factory.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/factories/line_item_factory'
require 'spree/testing_support/factories/order_factory'
require 'spree/testing_support/factories/tax_category_factory'
require 'spree/testing_support/factories/tax_rate_factory'
require 'spree/testing_support/factories/zone_factory'
end

FactoryBot.define do
factory :adjustment, class: 'Spree::Adjustment' do
order
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
end

FactoryBot.define do
factory :adjustment_reason, class: 'Spree::AdjustmentReason' do
sequence(:name) { |n| "Refund for return ##{n}" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
end

FactoryBot.define do
factory :calculator, aliases: [:flat_rate_calculator], class: 'Spree::Calculator::FlatRate' do
preferred_amount { 10.0 }
Expand Down
8 changes: 0 additions & 8 deletions core/lib/spree/testing_support/factories/carton_factory.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/factories/shipment_factory'
require 'spree/testing_support/factories/inventory_unit_factory'
end

FactoryBot.define do
factory :carton, class: 'Spree::Carton' do
address
Expand Down
5 changes: 0 additions & 5 deletions core/lib/spree/testing_support/factories/country_factory.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
end

require 'carmen'

FactoryBot.define do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
end

FactoryBot.define do
factory :credit_card, class: 'Spree::CreditCard' do
verification_value { 123 }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/factories/stock_location_factory'
require 'spree/testing_support/factories/order_factory'
require 'spree/testing_support/factories/return_item_factory'
end

FactoryBot.define do
factory :customer_return, class: 'Spree::CustomerReturn' do
association(:stock_location, factory: :stock_location)
Expand Down
5 changes: 0 additions & 5 deletions core/lib/spree/testing_support/factories/image_factory.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
end

FactoryBot.define do
factory :image, class: 'Spree::Image' do
attachment { Spree::Core::Engine.root.join('lib', 'spree', 'testing_support', 'fixtures', 'blank.jpg').open }
Expand Down
10 changes: 0 additions & 10 deletions core/lib/spree/testing_support/factories/inventory_unit_factory.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/factories/line_item_factory'
require 'spree/testing_support/factories/variant_factory'
require 'spree/testing_support/factories/order_factory'
require 'spree/testing_support/factories/shipment_factory'
end

FactoryBot.define do
factory :inventory_unit, class: 'Spree::InventoryUnit' do
transient do
Expand Down
8 changes: 0 additions & 8 deletions core/lib/spree/testing_support/factories/line_item_factory.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/factories/order_factory'
require 'spree/testing_support/factories/product_factory'
end

FactoryBot.define do
factory :line_item, class: 'Spree::LineItem' do
quantity { 1 }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/factories/product_factory'
require 'spree/testing_support/factories/option_type_factory'
end

FactoryBot.define do
factory :option_type, class: 'Spree::OptionType' do
sequence(:name) { |n| "foo-size-#{n}" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
end

FactoryBot.define do
factory :option_value, class: 'Spree::OptionValue' do
sequence(:name) { |n| "Size-#{n}" }
Expand Down
12 changes: 0 additions & 12 deletions core/lib/spree/testing_support/factories/order_factory.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/factories/address_factory'
require 'spree/testing_support/factories/shipment_factory'
require 'spree/testing_support/factories/store_factory'
require 'spree/testing_support/factories/user_factory'
require 'spree/testing_support/factories/line_item_factory'
require 'spree/testing_support/factories/payment_factory'
end

FactoryBot.define do
factory :order, class: 'Spree::Order' do
user
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/factories/order_factory'
require 'spree/testing_support/factories/promotion_factory'
end

FactoryBot.define do
factory :order_promotion, class: 'Spree::OrderPromotion' do
association :order
Expand Down
10 changes: 0 additions & 10 deletions core/lib/spree/testing_support/factories/payment_factory.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/factories/payment_method_factory'
require 'spree/testing_support/factories/credit_card_factory'
require 'spree/testing_support/factories/order_factory'
require 'spree/testing_support/factories/store_credit_factory'
end

FactoryBot.define do
factory :payment, aliases: [:credit_card_payment], class: 'Spree::Payment' do
association(:payment_method, factory: :credit_card_payment_method)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
end

FactoryBot.define do
factory :payment_method, aliases: [:credit_card_payment_method], class: 'Spree::PaymentMethod::BogusCreditCard' do
name { 'Credit Card' }
Expand Down
7 changes: 0 additions & 7 deletions core/lib/spree/testing_support/factories/price_factory.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/factories/variant_factory'
end

FactoryBot.define do
factory :price, class: 'Spree::Price' do
variant
Expand Down
11 changes: 0 additions & 11 deletions core/lib/spree/testing_support/factories/product_factory.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/sequences'
require 'spree/testing_support/factories/shipping_category_factory'
require 'spree/testing_support/factories/stock_location_factory'
require 'spree/testing_support/factories/tax_category_factory'
require 'spree/testing_support/factories/product_option_type_factory'
end

FactoryBot.define do
factory :base_product, class: 'Spree::Product' do
sequence(:name) { |n| "Product ##{n} - #{Kernel.rand(9999)}" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/factories/product_factory'
require 'spree/testing_support/factories/option_type_factory'
end

FactoryBot.define do
factory :product_option_type, class: 'Spree::ProductOptionType' do
product
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/factories/product_factory'
require 'spree/testing_support/factories/property_factory'
end

FactoryBot.define do
factory :product_property, class: 'Spree::ProductProperty' do
product
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
end

FactoryBot.define do
factory :promotion_category, class: 'Spree::PromotionCategory' do
name { 'Promotion Category' }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/sequences'
require 'spree/testing_support/factories/promotion_factory'
end

FactoryBot.define do
factory :promotion_code, class: 'Spree::PromotionCode' do
promotion
Expand Down
8 changes: 0 additions & 8 deletions core/lib/spree/testing_support/factories/promotion_factory.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/factories/promotion_code_factory'
require 'spree/testing_support/factories/variant_factory'
end

FactoryBot.define do
factory :promotion, class: 'Spree::Promotion' do
name { 'Promo' }
Expand Down
5 changes: 0 additions & 5 deletions core/lib/spree/testing_support/factories/property_factory.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking
end

FactoryBot.define do
factory :property, class: 'Spree::Property' do
name { 'baseball_cap_color' }
Expand Down
8 changes: 0 additions & 8 deletions core/lib/spree/testing_support/factories/refund_factory.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

require 'spree/testing_support/factories/payment_factory'
require 'spree/testing_support/factories/refund_reason_factory'
end

FactoryBot.define do
sequence(:refund_transaction_id) { |n| "fake-refund-transaction-#{n}" }

Expand Down
Loading

0 comments on commit d64b79f

Please sign in to comment.