Merge pull request #4889 from luisramos0/3-0-prod-set

[Spree 2.1] Fix ProductSet spec (1 broken spec)
This commit is contained in:
Luis Ramos
2020-03-20 19:33:19 +00:00
committed by GitHub
2 changed files with 6 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
class Spree::ProductSet < ModelSet
def initialize(attributes = {})
super(Spree::Product, [], attributes, proc { |attrs| attrs[:product_id].blank? })
super(Spree::Product, [], attributes)
end
def save
@@ -34,11 +34,9 @@ class Spree::ProductSet < ModelSet
split_taxon_ids!(attributes)
product = find_model(@collection, attributes[:id])
if product.nil?
@klass.new(attributes).save unless @reject_if.andand.call(attributes)
else
update_product(product, attributes)
end
return if product.nil?
update_product(product, attributes)
end
def split_taxon_ids!(attributes)

View File

@@ -12,7 +12,6 @@ describe Spree::ProductSet do
let(:collection_hash) do
{
0 => {
product_id: 11,
name: 'a product',
price: 2.0,
supplier_id: create(:enterprise).id,
@@ -25,11 +24,10 @@ describe Spree::ProductSet do
}
end
it 'creates it with the specified attributes' do
it 'does not create a new product' do
product_set.save
expect(Spree::Product.last.attributes)
.to include('name' => 'a product')
expect(Spree::Product.last).to be nil
end
end