Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: vitrue/spree
...
head fork: vitrue/spree
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 11 additions and 1 deletion.
  1. +3 −1 core/app/models/product.rb
  2. +8 −0 core/spec/models/product_spec.rb
View
4 core/app/models/product.rb
@@ -78,7 +78,9 @@ class Product < ActiveRecord::Base
#RAILS 3 TODO - this scope doesn't match the original 2.3.x version, needs attention (but it works)
scope :active, lambda{ not_deleted.available }
- scope :on_hand, where("products.count_on_hand > 0")
+ # scope :on_hand, where("products.count_on_hand > 0")
+ scope :on_hand, where("id in (select product_id from variants group by product_id having sum(count_on_hand) > 0)")
+ # scope :deals, where("id in (select distinct product_id from deals)")
if (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL')
if ActiveRecord::Base.connection.tables.include?("products")
View
8 core/spec/models/product_spec.rb
@@ -85,6 +85,14 @@
end
end
+ context "on_hand" do
+ let(:product) { Factory(:product) }
+ let(:variant) { Factory(:variant, :on_hand => 123)}
+ it 'uses variant\'s on_hand instead of product' do
+ Product.on_hand.find(variant.product.id).should eql variant.product
+ end
+ end
+
end

No commit comments for this range

Something went wrong with that request. Please try again.