Skip to content

Commit

Permalink
Merge pull request #1605 from mamhoff/use-current-store-cart-tax-coun…
Browse files Browse the repository at this point in the history
…try-iso-for-frontend-pricing

Make frontend prices depend on `store.cart_tax_country_iso`
  • Loading branch information
jhawthorn authored Nov 25, 2016
2 parents a510d5f + 51100ef commit 0cc914e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Solidus 2.1.0 (master, unreleased)

* Make frontend prices depend on `store.cart_tax_country_iso`

Prices in the frontend now depend on `store.cart_tax_country_iso` instead of `Spree::Config.admin_vat_country_iso`.

* Deprecate methods related to Spree::Order#tax_zone

We're not using `Spree::Order#tax_zone`, `Spree::Zone.default_tax`,
Expand Down
3 changes: 2 additions & 1 deletion core/lib/spree/core/controller_helpers/pricing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ module Pricing

def current_pricing_options
Spree::Config.pricing_options_class.new(
currency: current_store.try!(:default_currency).presence || Spree::Config[:currency]
currency: current_store.try!(:default_currency).presence || Spree::Config[:currency],
country_iso: current_store.try!(:cart_tax_country_iso).presence
)
end

Expand Down
16 changes: 16 additions & 0 deletions core/spec/lib/spree/core/controller_helpers/pricing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,21 @@ class FakesController < ApplicationController
it { is_expected.to eq('EUR') }
end
end

context "country_iso" do
subject { controller.current_pricing_options.country_iso }

let(:store) { FactoryGirl.create(:store, cart_tax_country_iso: cart_tax_country_iso) }

context "when the store has a cart tax country set" do
let(:cart_tax_country_iso) { "DE" }
it { is_expected.to eq("DE") }
end

context "when the store has no cart tax country set" do
let(:cart_tax_country_iso) { nil }
it { is_expected.to be_nil }
end
end
end
end

0 comments on commit 0cc914e

Please sign in to comment.