add spec for clearing authorizations to credit_card_controller_spec

This commit is contained in:
Andy Brett
2020-12-04 14:12:15 -08:00
parent d0098e190f
commit cc00f24569

View File

@@ -69,7 +69,7 @@ describe Spree::CreditCardsController, type: :controller do
end
end
describe "#update" do
describe "#update card to be the default card" do
let(:params) { { format: :json, credit_card: { is_default: true } } }
context "when the specified credit card is not found" do
before { params[:id] = 123 }
@@ -112,6 +112,23 @@ describe Spree::CreditCardsController, type: :controller do
expect(json_response['flash']['error']).to eq I18n.t(:card_could_not_be_updated)
end
end
context "and there are existing authorizations for the user" do
let!(:customer1) { create(:customer, allow_charges: true) }
let!(:customer2) { create(:customer, allow_charges: true) }
it "removes the authorizations" do
customer1.user = card.user
customer2.user = card.user
customer1.save
customer2.save
expect(customer1.reload.allow_charges).to be true
expect(customer2.reload.allow_charges).to be true
spree_put :update, params
expect(customer1.reload.allow_charges).to be false
expect(customer2.reload.allow_charges).to be false
end
end
end
end
end