Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix duplicate result if name contains SKU

  • Loading branch information...
commit 55ac76d8f6daf2800b9073bbfb0e01347249fb0a 1 parent 0f6e7fe
@jphpsf authored
View
2  core/app/controllers/spree/admin/products_controller.rb
@@ -108,7 +108,7 @@ def collection
tmp = super.where(["#{Variant.table_name}.sku #{LIKE} ?", "%#{params[:q]}%"])
tmp = tmp.includes(:variants_including_master).limit(params[:limit] || 10)
- @collection.concat(tmp)
+ @collection.concat(tmp).uniq!
end
@collection
end
View
7 core/spec/controllers/spree/admin/products_controller_spec.rb
@@ -51,6 +51,13 @@
assigns[:collection].should_not be_empty
assigns[:collection].should include(product)
end
+
+ it "should not return duplicate results if name contains SKU" do
+ product = create(:product, :sku => "ABC123", :name => "ABC product")
+ spree_xhr_get :index, { :q => "ABC", :format => :json }
+ assigns[:collection].should_not be_empty
+ assigns[:collection].length.should == 1
+ end
end
context "creating a product" do
Please sign in to comment.
Something went wrong with that request. Please try again.