-
-
Notifications
You must be signed in to change notification settings - Fork 708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bye bye Spree] Make OFN independent of all spree spec factories #5943
Merged
sauloperez
merged 36 commits into
openfoodfoundation:master
from
luisramos0:spree_factories
Aug 27, 2020
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
9390fd6
Remove all factories from spree so we can see exactly what factories …
luisramos0 e561bcc
Bring address factory from spree_core and merge with modification
luisramos0 172a12d
Bring credit_card factory from spree_core and merge with modification
luisramos0 aa90546
Bring payment factory from spree_core and merge with modification
luisramos0 e1fb13b
Bring payment method factory from spree_core and merge with modification
luisramos0 6819042
Bring options factories from spree_core and merge with modification
luisramos0 313e6e2
Bring stock_location factory from spree_core and merge with modification
luisramos0 53a8fec
Bring shipping_category factory from spree_core and merge with modifi…
luisramos0 4ac6664
Replace FactoryGirl with FactoryBot weverywhere
luisramos0 8d74c69
Bring order factory from spree_core and merge with modification
luisramos0 859d34c
Remove nice trick to reuse traits by copy pasting the traits to each of
luisramos0 acb1c41
Bring shipment factory from spree_core and merge with modification
luisramos0 ad8c41e
Bring shipping_method factory from spree_core and merge with modifica…
luisramos0 204e397
Bring user factory from spree_core and merge with modification
luisramos0 f6f6d9b
Bring variant factory from spree_core and merge with modification
luisramos0 4dd1a52
Bring random_email and random description from spree_core factories
luisramos0 9e7e63c
Bring line_item factory from spree_core
luisramos0 e2a8654
Bring adjustment factory from spree_core
luisramos0 ee65b4b
Bring taxon and taxonomy factories from spree_core
luisramos0 aa00756
Bring product factory from spree_core and merge with modification
luisramos0 6d05de7
Fix problem with product shipping category factory
luisramos0 6d9250c
Bring tax category factory from spree_core and fix a problem with the…
luisramos0 a432bbf
Fix problem with shipping method's shipping category creation
luisramos0 f56fa0b
Bring calculator factories from spree_core
luisramos0 2921994
Fix problem with shipment's stock location creation
luisramos0 2abbfad
Remove the need to import both :role and :state factory to OFN
luisramos0 4048957
Bring the final batch of factories from spree_core
luisramos0 1ddda92
Move factories from generic factories file to their respective factor…
luisramos0 cd22361
Fix shipping category factory
luisramos0 4de4cc6
Fix stock location factory
luisramos0 f627741
Simplify stock location factory and fix related issues in several fac…
luisramos0 5568fd5
Fix problem in order factory
luisramos0 41d67d8
Fix estimator spec
luisramos0 274cdef
Remove commented code
luisramos0 f9aac02
Run rubocop -a
luisramos0 94d1d5f
Run rubocop -a on spec/factories
luisramos0 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :adjustment, class: Spree::Adjustment do | ||
association(:adjustable, factory: :order) | ||
amount 100.0 | ||
label 'Shipping' | ||
association(:source, factory: :shipment) | ||
eligible true | ||
end | ||
end |
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :country, class: Spree::Country do | ||
iso_name 'UNITED STATES' | ||
name 'United States of America' | ||
iso 'US' | ||
iso3 'USA' | ||
numcode 840 | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# 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 | ||
end | ||
|
||
FactoryBot.define do | ||
factory :credit_card, class: TestCard do | ||
verification_value 123 | ||
month 12 | ||
year { Time.zone.now.year + 1 } | ||
number '4111111111111111' | ||
|
||
cc_type 'visa' | ||
end | ||
|
||
# A card that has been added to the user's profile and can be re-used. | ||
factory :stored_credit_card, parent: :credit_card do | ||
gateway_customer_profile_id "cus_F2T..." | ||
gateway_payment_profile_id "card_1EY..." | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :inventory_unit, class: Spree::InventoryUnit do | ||
variant | ||
order | ||
state 'on_hand' | ||
association(:shipment, factory: :shipment, state: 'pending') | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :line_item, class: Spree::LineItem do | ||
quantity 1 | ||
price { BigDecimal('10.00') } | ||
order | ||
variant | ||
end | ||
|
||
factory :line_item_with_shipment, parent: :line_item do | ||
transient do | ||
shipping_fee 3 | ||
shipping_method nil | ||
end | ||
|
||
after(:build) do |line_item, evaluator| | ||
shipment = line_item.order.reload.shipments.first | ||
if shipment.nil? | ||
shipping_method = evaluator.shipping_method | ||
unless shipping_method | ||
shipping_method = create(:shipping_method_with, :shipping_fee, shipping_fee: evaluator.shipping_fee) | ||
shipping_method.distributors << line_item.order.distributor if line_item.order.distributor | ||
end | ||
shipment = create(:shipment_with, :shipping_method, shipping_method: shipping_method, | ||
order: line_item.order) | ||
end | ||
line_item.target_shipment = shipment | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :option_value, class: Spree::OptionValue do | ||
name 'Size' | ||
presentation 'S' | ||
option_type | ||
end | ||
|
||
factory :option_type, class: Spree::OptionType do | ||
name 'foo-size' | ||
presentation 'Size' | ||
|
||
# Prevent inconsistent ordering in specs when all option types have the same (0) position | ||
sequence(:position) | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the magic of this PR: no spree factories used.