Skip to content
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

Spree::ProductDuplicator does not duplicate the product price. #4970

Closed
Roddoric opened this issue Mar 8, 2023 · 1 comment
Closed

Spree::ProductDuplicator does not duplicate the product price. #4970

Roddoric opened this issue Mar 8, 2023 · 1 comment

Comments

@Roddoric
Copy link
Contributor

Roddoric commented Mar 8, 2023

Until v3.2.3 duplicating a product duplicated the price.
Since v3.2.4 the product duplication does not duplicate the price.

Looks like it comes from the PR #4639 :/
Reproduced in #4971

The code looks like price is supposed to be copied:
Spree::ProductDuplicator#duplicate_master

    def duplicate_master
      master = product.master
      master.dup.tap do |new_master|
        new_master.sku = "COPY OF #{master.sku}"
        new_master.deleted_at = nil
        new_master.images = master.images.map { |image| duplicate_image image } if @include_images
        new_master.price = master.price
      end
    end

Solidus Version: 3.3.1 (Appeared in 3.2.4 but we went from 3.0.8 to 3.3.1)

To Reproduce

Add this test in solidus/core/spec/models/spree/product_duplicator_spec.rb around l.60 ( context "product attributes" )

      it "will set the same price" do
        expect(new_product.reload.price).to eql product.price
      end
➜  solidus git:(v3.2.4) ✗ (cd core && env DB=postgresql bundle exec rspec /Users/j.garibotti/work/solidus/core/spec/models/spree/product_duplicator_spec.rb)

Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}

Randomized with seed 41198
.F..........

Failures:

  1) Spree::ProductDuplicator product attributes will set the same price price
     Failure/Error: expect(new_product.reload.price).to eql product.price
     
       expected: #<BigDecimal: 19.99>
            got: nil
     
       (compared using eql?)
     # ./spec/models/spree/product_duplicator_spec.rb:65:in `block (3 levels) in <module:Spree>'

Finished in 2.01 seconds (files took 2.39 seconds to load)
12 examples, 1 failure

Failed examples:

rspec ./spec/models/spree/product_duplicator_spec.rb:64 # Spree::ProductDuplicator product attributes will set the same price price

Randomized with seed 41198

Current behavior

Does not duplicate the price.

Expected behavior

The new_product as the same price as the duplicated_product.

@Roddoric
Copy link
Contributor Author

Closed as #4971 is merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant