test: add spec for Spree::CreditCard#brand= setter to verify card type reformatting

This commit is contained in:
Zil Norvilis
2026-02-22 22:28:40 +02:00
parent ce94b394b2
commit 2cfd386ad7

View File

@@ -198,6 +198,15 @@ RSpec.describe Spree::CreditCard do
end
end
context "#brand=" do
let(:credit_card) { build(:credit_card) }
it "delegates to #cc_type= and reformats the card type" do
credit_card.brand = 'mastercard'
expect(credit_card.cc_type).to eq 'master'
end
end
context "on save" do
it "converts the card type format" do
expect_any_instance_of(described_class).to receive(:reformat_card_type!).