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
Fixed Product.in_taxon to not return duplicates #1962
Conversation
This commit causes a build to break: http://travis-ci.org/#!/spree/spree/jobs/2483894. I will investigate. |
end | ||
|
||
it "calling Product.in_taxon should not return duplicate records" do | ||
Spree::Product.in_taxon(@taxon).length.should == 1 |
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.
You're using length
here because count
returned an incorrect value, right?
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.
With count
, ActiveRecord performs the counting on the database using a "SELECT DISTINCT COUNT(*) FROM "spree_products" …
which leads to a wrong result
I am going to revert this commit due to the broken build. I cannot figure out how to fix the broken spec. |
I see, Do you think, using |
Yes, that appears to work. I've merged this PR to master, 1-2-stable and 1-1-stable. Thanks! |
When a product is assigned to a parent taxon and that parent’s child taxon,
Product.in_taxon(taxon)
should not return duplicate records.