Skip to content

Commit

Permalink
Fix specs due to upstream changes on states_required field
Browse files Browse the repository at this point in the history
Country factory was changed to assign a realistic states_required field.
We update our test suite to account for this change.

See solidusio/solidus#4272

[skip ci]
  • Loading branch information
waiting-for-dev committed Aug 14, 2023
1 parent 017dc8e commit fad0d1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
]
}

let(:country_id) { SolidusGraphqlApi::Schema.id_from_object(create(:country), nil, nil) }
let(:country_id) { SolidusGraphqlApi::Schema.id_from_object(create(:country, states_required: false), nil, nil) }
let(:address) {
address = build_stubbed(:address).slice(:address1, :city, :phone, :zipcode)
address[:countryId] = country_id
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/queries/countries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
end

context 'when countries exists' do
let!(:us_country) { create(:country, :with_states, id: 1) }
let!(:it_country) { create(:country, id: 2, iso: 'IT') }
let!(:us_country) { create(:country, :with_states, id: 1, states_required: false) }
let!(:it_country) { create(:country, id: 2, iso: 'IT', states_required: false) }

it { is_expected.to match_response(:countries) }
end
Expand Down
9 changes: 7 additions & 2 deletions spec/integration/queries/current_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
bill_address: bill_address)
}

let(:ship_address) { create(:ship_address, id: 1, zipcode: 10_001) }
let(:bill_address) { create(:bill_address, id: 2, zipcode: 10_002) }
# Previos to Solidus v3.3, states_required was always false and the state was
# always automatically assigned. We force the behavior here to have the same
# response for any Solidus version.
let(:country) { create(:country, states_required: false) }
let(:state) { create(:state, name: "Alabama", abbr: "AL", country: country)}
let(:ship_address) { create(:ship_address, id: 1, zipcode: 10_001, country: country, state: state) }
let(:bill_address) { create(:bill_address, id: 2, zipcode: 10_002, country: country, state: state) }
let(:credit_card) {
create(:credit_card,
user: user,
Expand Down

0 comments on commit fad0d1e

Please sign in to comment.