Created
December 14, 2014 14:55
-
-
Save paneq/dd47bcc379fa8e1dc005 to your computer and use it in GitHub Desktop.
Mutations found on initial run http://youtu.be/xrMsQxy_YO0 / https://github.com/paneq/inventory-mutation
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
evil:Inventory#change_quantity:/home/rupert/ssd/rupert/develop/paneq/inventory-mutation/lib/inventory.rb:18:a2bf6 | |
@@ -1,8 +1,8 @@ | |
def change_quantity(identifier, qty) | |
if (((qty - @reserved_quantity[identifier].sum) - @sold_quantity[identifier].sum) < 0) | |
- raise(StandardError, "quantity too low") | |
+ raise | |
end | |
@available_quantity[identifier] << (-@available_quantity[identifier].last) | |
@available_quantity[identifier] << qty | |
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
evil:Inventory#initialize:/home/rupert/ssd/rupert/develop/paneq/inventory-mutation/lib/inventory.rb:4:1c049 | |
@@ -1,12 +1,12 @@ | |
def initialize | |
@available_quantity = Hash.new do |hash, key| | |
- hash[key] = [0] | |
+ hash[key] = [] | |
end | |
@reserved_quantity = Hash.new do |hash, key| | |
hash[key] = [0] | |
end | |
@sold_quantity = Hash.new do |hash, key| | |
hash[key] = [0] | |
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
evil:Inventory#refund_product:/home/rupert/ssd/rupert/develop/paneq/inventory-mutation/lib/inventory.rb:48:a9f80 | |
@@ -1,7 +1,7 @@ | |
def refund_product(identifier, qty) | |
- if (qty > sold_quantity(identifier)) | |
+ if (qty >= sold_quantity(identifier)) | |
raise(StandardError, "quantity too big") | |
end | |
@sold_quantity[identifier] << (-qty) | |
end | |
----------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment