mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-04 02:31:33 +00:00
test: Add specs for the stripe_card_options helper method, verifying card formatting and month padding.
This commit is contained in:
@@ -193,4 +193,25 @@ RSpec.describe CheckoutHelper do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#stripe_card_options" do
|
||||
let(:year) { Time.zone.now.year + 1 }
|
||||
let(:card) { create(:credit_card, cc_type: 'visa', last_digits: '1111', month: 1, year:) }
|
||||
let(:cards) { [card] }
|
||||
|
||||
it "formats credit cards for Stripe options" do
|
||||
options = helper.stripe_card_options(cards)
|
||||
|
||||
expect(options).to eq([
|
||||
["visa 1111 Exp:01/#{year}", card.id]
|
||||
])
|
||||
end
|
||||
|
||||
it "zero-pads the month" do
|
||||
card.update(month: 5)
|
||||
options = helper.stripe_card_options(cards)
|
||||
|
||||
expect(options.first.first).to match(%r{05/#{year}})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user