-
-
Notifications
You must be signed in to change notification settings - Fork 516
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
Fix inventory quantity errors to be tied to organization, not storage location (Fixes #4647) #4804
Changes from 6 commits
c5ea407
01a3d87
7b878db
3d1ec15
6703c90
c198965
6d00cbc
e61a812
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,5 +59,38 @@ | |
end | ||
end | ||
end | ||
|
||
trait :with_items_mixed do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is only used in one place and is pretty complex. I'd much rather just have that one spec create this data rather than adding it to the factory. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure thing. See 6d00cbc. |
||
with_items | ||
|
||
transient do | ||
second_item_quantity { 100 } | ||
second_item { nil } | ||
end | ||
|
||
after(:create) do |storage_location, evaluator| | ||
if evaluator.second_item.nil? && !evaluator.second_item_count.zero? | ||
second_item_count = evaluator.item_count | ||
|
||
TestInventory.create_inventory( | ||
storage_location.organization, { | ||
storage_location.id => (0...second_item_count).to_h do | ||
second_item = create(:second_item, organization_id: storage_location.organization_id) | ||
[second_item.id, evaluator.item_quantity] | ||
end | ||
} | ||
) | ||
elsif evaluator.second_item | ||
second_item = evaluator.second_item | ||
second_item.save if second_item.new_record? | ||
TestInventory.create_inventory( | ||
storage_location.organization, | ||
{ | ||
storage_location.id => {second_item.id => evaluator.item_quantity} | ||
} | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
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.
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 a really lovely refactor. Thanks for suggesting it. See 6d00cbc.