Skip to content
This repository has been archived by the owner on Feb 27, 2021. It is now read-only.

Fix invalid checkout price issue #65

Merged

Conversation

nmccafferty
Copy link
Contributor

Fix for #64

The issue seems to stem from the call to price_including_vat_for against the variant. This delegates the method onto it's price object, but from the variant it has no way to know whether the price is a EUR / USD object, it instead uses the Spree::Config[:currency] value to determine which price to use and comes back with the USD object instead of the EUR object.

Therefore I expect a change needs to be applied where this info is known, in the line_item.rb method update_price to get back the correct price object and invoke price_including_vat_for directly.

expect(line_item).to receive(:variant_id).and_return(1001)

expect(Spree::Price).to receive(:where).with(
currency: 'EUR',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

describe 'update_price' do
let(:price) { double 'price' }
let(:order) { create :order, currency: 'EUR' }
let(:line_item) { create :line_item, order_id: order.id, currency: 'EUR' }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

describe Spree::LineItem do
describe 'update_price' do
let(:price) { double 'price' }
let(:order) { create :order, currency: 'EUR' }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@@ -0,0 +1,24 @@
describe Spree::LineItem do
describe 'update_price' do
let(:price) { double 'price' }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@@ -0,0 +1,24 @@
describe Spree::LineItem do
describe 'update_price' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@@ -0,0 +1,24 @@
describe Spree::LineItem do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing frozen string literal comment.

@@ -0,0 +1,10 @@
Spree::LineItem.class_eval do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing frozen string literal comment.

@krzysiek1507
Copy link
Contributor

Hi @nmccafferty could you please make these changes against master?

@nmccafferty
Copy link
Contributor Author

@krzysiek1507 I had initially tried to make the changes against the master but a fresh bundle install fails, colleague has now confirmed this for me, he gets the same:

Bundler could not find compatible versions for gem "actionview":
  In Gemfile:
    spree_auth_devise was resolved to 3.2.0.alpha, which depends on
      devise (~> 4.0.0) was resolved to 4.0.0, which depends on
        railties (< 5.1, >= 4.1.0) was resolved to 4.1.1, which depends on
          actionpack (= 4.1.1) was resolved to 4.1.1, which depends on
            actionview (= 4.1.1)

    rspec-rails (~> 3.4.0) was resolved to 3.4.0, which depends on
      actionpack (< 4.3, >= 3.0) was resolved to 4.1.1, which depends on
        actionview (= 4.1.0)
Bundler could not find compatible versions for gem "activerecord":
  In Gemfile:
    spree was resolved to 3.2.0.beta1, which depends on
      spree_frontend (= 3.2.0.beta1) was resolved to 3.2.0.beta1, which depends on
        canonical-rails (~> 0.1.0) was resolved to 0.1.0, which depends on
          rails (< 5.1, >= 3.1) was resolved to 5.0.0, which depends on
            activerecord (= 4.2.0)

    spree was resolved to 3.2.0.beta1, which depends on
      spree_core (= 3.2.0.beta1) was resolved to 3.2.0.beta1, which depends on
        rails (~> 5.0.0) was resolved to 5.0.0, which depends on
          activerecord (= 5.0.0)
Bundler could not find compatible versions for gem "activesupport":
  In Gemfile:
    spree_auth_devise was resolved to 3.2.0.alpha, which depends on
      devise (~> 4.0.0) was resolved to 4.0.0, which depends on
        railties (< 5.1, >= 4.1.0) was resolved to 4.1.0, which depends on
          actionpack (= 4.1.0) was resolved to 4.1.0, which depends on
            activesupport (= 4.1.0)

    spree_auth_devise was resolved to 3.2.0.alpha, which depends on
      devise (~> 4.0.0) was resolved to 4.0.0, which depends on
        railties (< 5.1, >= 4.1.0) was resolved to 4.1.0, which depends on
          actionpack (= 4.1.0) was resolved to 4.1.0, which depends on
            activesupport (= 4.1.0)

    rspec-rails (~> 3.4.0) was resolved to 3.4.0, which depends on
      actionpack (< 4.3, >= 3.0) was resolved to 4.1.0, which depends on
        activesupport (= 3.0.0)

    factory_girl (~> 4.4) was resolved to 4.7.0, which depends on
      activesupport (>= 3.0.0)

    rspec-rails (~> 3.4.0) was resolved to 3.4.0, which depends on
      activesupport (< 4.3, >= 3.0)
Bundler could not find compatible versions for gem "rspec-expectations":
  In Gemfile:
    guard-rspec (>= 4.2.0) was resolved to 4.7.3, which depends on
      rspec (< 4.0, >= 2.99.0) was resolved to 3.5.0, which depends on
        rspec-expectations (~> 3.5.0)

    rspec-rails (~> 3.4.0) was resolved to 3.4.0, which depends on
      rspec-expectations (~> 3.4.0)

@arvindvyas
Copy link

arvindvyas commented Sep 22, 2016

@krzysiek1507

"Hi @nmccafferty could you please make these changes against master?"

why against when this issue fix for 3-1-stable ??

@krzysiek1507
Copy link
Contributor

@arvindvyas I think we want to fix it also in next versions ;) So we can fix it on master and cherry-pick to previous versions. Do you agree?

@arvindvyas
Copy link

@krzysiek1507 Don't you think it is important is fix stable branch first? if you don't fix it for un stable branch it is not that important .

@nmccafferty
Copy link
Contributor Author

@krzysiek1507 Is there any chance you can merge this in as it really is quite a critical issue in the project? I had tried to follow your request to add to master but the master build would not bundle as I've instructed before. I'll continue working with a patched version until you can sort this out.

@arvindvyas
Copy link

@nmccafferty seems they don't care!

@damianlegawiec
Copy link
Contributor

@nmccafferty @arvindvyas merged! Sorry for the long wait!

@damianlegawiec damianlegawiec merged commit 025220e into spree-contrib:3-1-stable Feb 8, 2017
damianlegawiec pushed a commit to spark-solutions/spree_multi_currency that referenced this pull request Feb 8, 2017
* Fix invalid checkout price issue

* Fix hound review
@damianlegawiec
Copy link
Contributor

@nmccafferty @arvindvyas btw. master branch supports 3.1, 3.2 and 3.3

damianlegawiec added a commit that referenced this pull request Feb 8, 2017
Fix invalid checkout price issue (#65)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants