Skip to content

Instantly share code, notes, and snippets.

@paneq
Created December 14, 2014 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paneq/dd47bcc379fa8e1dc005 to your computer and use it in GitHub Desktop.
Save paneq/dd47bcc379fa8e1dc005 to your computer and use it in GitHub Desktop.
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
-----------------------
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
-----------------------
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