Skip to content

Commit

Permalink
Add codeclimate badge
Browse files Browse the repository at this point in the history
Refactoring at stock_item notification.
  • Loading branch information
ddomingues committed Dec 12, 2014
1 parent 0236589 commit 2d6f50f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.8.0)
colorize (0.7.3)
colorize (0.7.4)
database_cleaner (1.3.0)
deface (1.0.1)
colorize (>= 0.5.8)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Spree Waiting List
================
[![Code Climate](https://codeclimate.com/github/ddomingues/spree_waiting_list/badges/gpa.svg)](https://codeclimate.com/github/ddomingues/spree_waiting_list)

A waiting list extension for Spree.

Expand Down
4 changes: 4 additions & 0 deletions app/models/spree/product_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Spree::Product.class_eval do
has_many :stock_requests

def notify_waiting_list
stock_requests.without_variant.notified(false).each &:notify!
end
end
3 changes: 1 addition & 2 deletions app/models/spree/stock_item_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ def notify_availability
yield

if available
variant.stock_requests.notified(false).each &:notify!
variant.product.stock_requests.without_variant.notified(false).each &:notify!
variant.notify_waiting_list
end
end

Expand Down
5 changes: 5 additions & 0 deletions app/models/spree/variant_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ module Spree

Variant.class_eval do
has_many :stock_requests

def notify_waiting_list
stock_requests.notified(false).each &:notify!
product.notify_waiting_list
end
end

end

0 comments on commit 2d6f50f

Please sign in to comment.