Skip to content

Commit

Permalink
Update spec setup to reset state in before block
Browse files Browse the repository at this point in the history
In a recent change to core, an `after(:build)` hook was added to set the
state on the address record for countries which require states. This
interferes with the spec setup by ignoring the state attribute we were
setting to `nil`. Instead we have moved that to a `before` block so that
we can correctly setup the test address to not have a state.

Relevant change upstream - solidusio/solidus#4272

Co-authored-by: Andrew Stewart <andrew@super.gd>
  • Loading branch information
forkata and stewart committed Jan 20, 2023
1 parent 41ec909 commit f33b978
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions spec/super_good/solidus_taxjar/calculator_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ class TestProxy
end

context "with a missing state in CA" do
let(:address) { build :address, country_iso_code: "CA", state: nil }
let(:address) { build :address, country_iso_code: "CA" }

before { address.state = nil }

it { is_expected.to eq(true) }
end

context "with a missing state in US" do
let(:address) { build :address, country_iso_code: "US", state: nil }
let(:address) { build :address, country_iso_code: "US" }

before { address.state = nil }

it { is_expected.to eq(true) }
end

Expand Down

0 comments on commit f33b978

Please sign in to comment.