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

Fix Order#tax_address method #4429

Merged
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
2 changes: 1 addition & 1 deletion core/app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def tax_address
ship_address
else
bill_address
end || store.default_cart_tax_location
end || store&.default_cart_tax_location
end

def updater
Expand Down
24 changes: 20 additions & 4 deletions core/spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -467,16 +467,32 @@ def merge!(other_order, user = nil)
context "when tax_using_ship_address is true" do
let(:tax_using_ship_address) { true }

it 'returns the stores default cart tax location' do
expect(subject).to eq(store.default_cart_tax_location)
context "when the order is associated with a store" do
it 'returns the stores default cart tax location' do
expect(subject).to eq(store.default_cart_tax_location)
end
end

context "when the order is not associated with a store" do
let(:store) { nil }

it { is_expected.to be_nil }
end
end

context "when tax_using_ship_address is not true" do
let(:tax_using_ship_address) { false }

it 'returns the stores default cart tax location' do
expect(subject).to eq(store.default_cart_tax_location)
context "when the order is associated with a store" do
it 'returns the stores default cart tax location' do
expect(subject).to eq(store.default_cart_tax_location)
end
end

context "when the order is not associated with a store" do
let(:store) { nil }

it { is_expected.to be_nil }
end
end
end
Expand Down