Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Make nonce-only payment sources non-reusable #204

Merged
merged 1 commit into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/solidus_paypal_braintree/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def paypal?
end

def reusable?
true
token.present?
end

def credit_card?
Expand Down
16 changes: 16 additions & 0 deletions spec/models/solidus_paypal_braintree/source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,20 @@
it { is_expected.to be_nil }
end
end

describe '#reusable?' do
let(:payment_source) { described_class.new(token: token, nonce: nonce) }
let(:nonce) { 'nonce67890' }
subject { payment_source.reusable? }

context 'when source token is present' do
let(:token) { 'token12345' }
it { is_expected.to be_truthy }
end

context 'when source token is nil' do
let(:token) { nil }
it { is_expected.to be_falsy }
end
end
end