This repository has been archived by the owner on Sep 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
38 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,38 @@ | ||
require 'spree/testing_support/factories' | ||
|
||
# Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them. | ||
# | ||
# Example adding this to your spec_helper will load these Factories for use: | ||
# require 'solidus_stock_transfers/factories' | ||
|
||
FactoryBot.define do | ||
# Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them. | ||
# | ||
# Example adding this to your spec_helper will load these Factories for use: | ||
# require 'solidus_stock_transfers/factories' | ||
sequence(:source_code) { |n| "SRC#{n}" } | ||
sequence(:destination_code) { |n| "DEST#{n}" } | ||
|
||
factory :stock_transfer, class: 'Spree::StockTransfer' do | ||
source_location { Spree::StockLocation.create!(name: "Source Location", code: generate(:source_code), admin_name: "Source") } | ||
|
||
factory :stock_transfer_with_items do | ||
destination_location { Spree::StockLocation.create!(name: "Destination Location", code: generate(:destination_code), admin_name: "Destination") } | ||
|
||
after(:create) do |stock_transfer, _evaluator| | ||
variant_1 = create(:variant) | ||
variant_2 = create(:variant) | ||
|
||
variant_1.stock_items.find_by(stock_location: stock_transfer.source_location).set_count_on_hand(10) | ||
variant_2.stock_items.find_by(stock_location: stock_transfer.source_location).set_count_on_hand(10) | ||
|
||
stock_transfer.transfer_items.create(variant: variant_1, expected_quantity: 5) | ||
stock_transfer.transfer_items.create(variant: variant_2, expected_quantity: 5) | ||
|
||
stock_transfer.created_by = create(:admin_user) | ||
stock_transfer.save! | ||
end | ||
|
||
factory :receivable_stock_transfer_with_items do | ||
finalized_at { Time.current } | ||
shipped_at { Time.current } | ||
end | ||
end | ||
end | ||
end |
31 changes: 0 additions & 31 deletions
31
lib/spree/testing_support/factories/stock_transfer_factory.rb
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
.../factories/stock_transfer_factory_spec.rb → ...solidus_stock_transfers/factories_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters