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

Make frontend prices depend on store.cart_tax_country_iso #1605

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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