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

Commit

Permalink
Merge pull request #204 from geminimvp/non_reusable_nonces
Browse files Browse the repository at this point in the history
Make nonce-only payment sources non-reusable
  • Loading branch information
kennyadsl authored Jan 29, 2019
2 parents 0a050e4 + edd702e commit dde562b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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

0 comments on commit dde562b

Please sign in to comment.