solidus_braintree 3.3.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +7 -0
  3. data/.github/workflows/lint.yml +25 -0
  4. data/.github/workflows/test.yml +77 -0
  5. data/.rubocop.yml +5 -84
  6. data/.standard.yml +6 -0
  7. data/Gemfile +12 -17
  8. data/README.md +7 -5
  9. data/Rakefile +7 -7
  10. data/app/helpers/solidus_braintree/braintree_admin_helper.rb +4 -4
  11. data/app/models/solidus_braintree/avs_result.rb +34 -34
  12. data/app/models/solidus_braintree/base_record.rb +1 -1
  13. data/app/models/solidus_braintree/configuration.rb +11 -11
  14. data/app/models/solidus_braintree/gateway.rb +14 -16
  15. data/app/models/solidus_braintree/response.rb +9 -9
  16. data/app/models/solidus_braintree/source.rb +5 -5
  17. data/app/models/solidus_braintree/transaction.rb +2 -2
  18. data/app/models/solidus_braintree/transaction_address.rb +5 -5
  19. data/app/models/solidus_braintree/transaction_import.rb +2 -2
  20. data/app/{decorators/models/solidus_braintree/spree_store_decorator.rb → patches/models/solidus_braintree/spree_store_patch.rb} +1 -1
  21. data/app/{decorators/models/solidus_braintree/spree_user_decorator.rb → patches/models/solidus_braintree/spree_user_patch.rb} +2 -2
  22. data/bin/dummy-app +22 -3
  23. data/bin/rails-sandbox +4 -4
  24. data/bin/rspec +6 -0
  25. data/bin/sandbox +55 -31
  26. data/db/migrate/20161114231422_create_solidus_paypal_braintree_configurations.rb +2 -2
  27. data/db/migrate/20170508085402_add_not_null_constraint_to_sources_payment_type.rb +2 -2
  28. data/db/migrate/20230109080950_rename_solidus_paypal_braintree_source_type.rb +3 -3
  29. data/lib/controllers/api/solidus_braintree/client_tokens_controller.rb +2 -2
  30. data/lib/controllers/backend/solidus_braintree/configurations_controller.rb +4 -4
  31. data/lib/generators/solidus_braintree/install/install_generator.rb +48 -40
  32. data/lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/checkouts_controller.rb +7 -7
  33. data/lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/transactions_controller.rb +7 -7
  34. data/lib/generators/solidus_braintree/install/templates/app/helpers/solidus_braintree/braintree_checkout_helper.rb +5 -5
  35. data/{app/decorators/controllers/solidus_braintree/admin_payments_controller_decorator.rb → lib/patches/backend/controllers/solidus_braintree/admin_payments_controller_patch.rb} +1 -1
  36. data/lib/solidus_braintree/engine.rb +13 -24
  37. data/lib/solidus_braintree/extension_configuration.rb +1 -1
  38. data/lib/solidus_braintree/request_protection.rb +2 -2
  39. data/lib/solidus_braintree/version.rb +1 -1
  40. data/lib/solidus_braintree.rb +8 -8
  41. data/lib/solidus_paypal_braintree.rb +2 -2
  42. data/mise.toml +2 -0
  43. data/solidus_braintree.gemspec +23 -22
  44. metadata +59 -147
  45. data/.circleci/config.yml +0 -79
  46. data/lib/views/backend_v1.2/spree/admin/payments/source_forms/_braintree.html.erb +0 -16
  47. data/lib/views/backend_v2.4/spree/admin/shared/preference_fields/_hash.html.erb +0 -12
  48. data/spec/controllers/solidus_braintree/checkouts_controller_spec.rb +0 -99
  49. data/spec/controllers/solidus_braintree/client_tokens_controller_spec.rb +0 -55
  50. data/spec/controllers/solidus_braintree/configurations_controller_spec.rb +0 -73
  51. data/spec/controllers/solidus_braintree/transactions_controller_spec.rb +0 -183
  52. data/spec/fixtures/cassettes/admin/invalid_credit_card.yml +0 -63
  53. data/spec/fixtures/cassettes/admin/resubmit_credit_card.yml +0 -352
  54. data/spec/fixtures/cassettes/admin/valid_credit_card.yml +0 -412
  55. data/spec/fixtures/cassettes/braintree/create_profile.yml +0 -71
  56. data/spec/fixtures/cassettes/braintree/generate_token.yml +0 -63
  57. data/spec/fixtures/cassettes/braintree/token.yml +0 -63
  58. data/spec/fixtures/cassettes/checkout/invalid_credit_card.yml +0 -63
  59. data/spec/fixtures/cassettes/checkout/resubmit_credit_card.yml +0 -216
  60. data/spec/fixtures/cassettes/checkout/update.yml +0 -71
  61. data/spec/fixtures/cassettes/checkout/valid_credit_card.yml +0 -171
  62. data/spec/fixtures/cassettes/checkout/valid_venmo_transaction.yml +0 -599
  63. data/spec/fixtures/cassettes/gateway/authorize/credit_card/address.yml +0 -86
  64. data/spec/fixtures/cassettes/gateway/authorize/merchant_account/EUR.yml +0 -154
  65. data/spec/fixtures/cassettes/gateway/authorize/paypal/EUR.yml +0 -90
  66. data/spec/fixtures/cassettes/gateway/authorize/paypal/address.yml +0 -90
  67. data/spec/fixtures/cassettes/gateway/authorize.yml +0 -86
  68. data/spec/fixtures/cassettes/gateway/authorized_transaction.yml +0 -73
  69. data/spec/fixtures/cassettes/gateway/cancel/missing.yml +0 -63
  70. data/spec/fixtures/cassettes/gateway/cancel/refunds.yml +0 -272
  71. data/spec/fixtures/cassettes/gateway/cancel/void.yml +0 -201
  72. data/spec/fixtures/cassettes/gateway/capture.yml +0 -141
  73. data/spec/fixtures/cassettes/gateway/complete.yml +0 -157
  74. data/spec/fixtures/cassettes/gateway/credit.yml +0 -208
  75. data/spec/fixtures/cassettes/gateway/customer.yml +0 -79
  76. data/spec/fixtures/cassettes/gateway/purchase.yml +0 -87
  77. data/spec/fixtures/cassettes/gateway/settled_transaction.yml +0 -140
  78. data/spec/fixtures/cassettes/gateway/void.yml +0 -137
  79. data/spec/fixtures/cassettes/source/bin.yml +0 -295
  80. data/spec/fixtures/cassettes/source/card_type.yml +0 -267
  81. data/spec/fixtures/cassettes/source/last4.yml +0 -267
  82. data/spec/fixtures/cassettes/transaction/import/valid/capture.yml +0 -224
  83. data/spec/fixtures/cassettes/transaction/import/valid.yml +0 -71
  84. data/spec/fixtures/views/carts/_cart_footer.html.erb +0 -18
  85. data/spec/helpers/solidus_braintree/braintree_admin_helper_spec.rb +0 -17
  86. data/spec/helpers/solidus_braintree/braintree_checkout_helper_spec.rb +0 -70
  87. data/spec/models/solidus_braintree/address_spec.rb +0 -71
  88. data/spec/models/solidus_braintree/avs_result_spec.rb +0 -317
  89. data/spec/models/solidus_braintree/gateway_spec.rb +0 -774
  90. data/spec/models/solidus_braintree/response_spec.rb +0 -280
  91. data/spec/models/solidus_braintree/source_spec.rb +0 -555
  92. data/spec/models/solidus_braintree/transaction_address_spec.rb +0 -235
  93. data/spec/models/solidus_braintree/transaction_import_spec.rb +0 -302
  94. data/spec/models/solidus_braintree/transaction_spec.rb +0 -86
  95. data/spec/models/spree/store_spec.rb +0 -14
  96. data/spec/requests/spree/api/orders_controller_spec.rb +0 -36
  97. data/spec/solidus_braintree_spec_helper.rb +0 -9
  98. data/spec/support/solidus_braintree/capybara.rb +0 -7
  99. data/spec/support/solidus_braintree/factories.rb +0 -55
  100. data/spec/support/solidus_braintree/gateway_helpers.rb +0 -29
  101. data/spec/support/solidus_braintree/order_ready_for_payment.rb +0 -44
  102. data/spec/support/solidus_braintree/order_walkthrough.rb +0 -87
  103. data/spec/support/solidus_braintree/vcr.rb +0 -38
  104. data/spec/support/solidus_braintree/with_prepended_view_fixtures.rb +0 -19
  105. data/spec/system/backend/configuration_spec.rb +0 -23
  106. data/spec/system/backend/new_payment_spec.rb +0 -136
  107. data/spec/system/frontend/braintree_credit_card_checkout_spec.rb +0 -199
  108. data/spec/system/frontend/paypal_checkout_spec.rb +0 -168
  109. data/spec/system/frontend/venmo_checkout_spec.rb +0 -193
@@ -1,555 +0,0 @@
1
- require 'solidus_braintree_spec_helper'
2
- require 'support/solidus_braintree/order_ready_for_payment'
3
-
4
- RSpec.describe SolidusBraintree::Source, type: :model do
5
- include_context 'when order is ready for payment'
6
-
7
- it 'is invalid without a payment_type set' do
8
- expect(described_class.new).to be_invalid
9
- end
10
-
11
- it 'is invalid with payment_type set to unknown type' do
12
- expect(described_class.new(payment_type: 'AndroidPay')).to be_invalid
13
- end
14
-
15
- describe 'attributes' do
16
- context 'with paypal_funding_source' do
17
- subject { build(:solidus_braintree_source, :paypal) }
18
-
19
- it 'can be nil' do
20
- subject.paypal_funding_source = nil
21
-
22
- expect(subject).to be_valid
23
- end
24
-
25
- it 'makes empty strings nil' do
26
- subject.paypal_funding_source = ''
27
-
28
- result = subject.save
29
-
30
- expect(result).to be(true)
31
- expect(subject.paypal_funding_source).to be_nil
32
- end
33
-
34
- it 'gets correctly mapped as an enum' do
35
- subject.paypal_funding_source = 'applepay'
36
-
37
- result = subject.save
38
-
39
- expect(result).to be(true)
40
- expect(subject.paypal_funding_source).to eq('applepay')
41
- expect(subject.applepay_funding?).to be(true)
42
- end
43
-
44
- it "doesn't become nil when the payment_type is a PAYPAL" do
45
- subject.payment_type = described_class::PAYPAL
46
- subject.paypal_funding_source = 'venmo'
47
-
48
- result = subject.save
49
-
50
- expect(result).to be(true)
51
- expect(subject.venmo_funding?).to be(true)
52
- end
53
-
54
- it 'becomes nil when the payment_type is a CREDIT CARD' do
55
- subject.payment_type = described_class::CREDIT_CARD
56
- subject.paypal_funding_source = 'venmo'
57
-
58
- result = subject.save
59
-
60
- expect(result).to be(true)
61
- expect(subject.paypal_funding_source).to be_nil
62
- end
63
-
64
- it 'becomes nil when the payment_type is APPLE PAY' do
65
- subject.payment_type = described_class::APPLE_PAY
66
- subject.paypal_funding_source = 'venmo'
67
-
68
- result = subject.save
69
-
70
- expect(result).to be(true)
71
- expect(subject.paypal_funding_source).to be_nil
72
- end
73
- end
74
- end
75
-
76
- describe '#payment_method' do
77
- it 'uses spree_payment_method' do
78
- expect(described_class.new.build_payment_method).to be_a Spree::PaymentMethod
79
- end
80
- end
81
-
82
- describe '#imported' do
83
- it 'is always false' do
84
- expect(described_class.new.imported).not_to be_truthy
85
- end
86
- end
87
-
88
- describe "#actions" do
89
- it "supports capture, void, and credit" do
90
- expect(described_class.new.actions).to eq %w[capture void credit]
91
- end
92
- end
93
-
94
- describe "#can_capture?" do
95
- subject { described_class.new.can_capture?(payment) }
96
-
97
- context "when the payment state is pending" do
98
- let(:payment) { build(:payment, state: "pending") }
99
-
100
- it { is_expected.to be_truthy }
101
- end
102
-
103
- context "when the payment state is checkout" do
104
- let(:payment) { build(:payment, state: "checkout") }
105
-
106
- it { is_expected.to be_truthy }
107
- end
108
-
109
- context "when the payment is completed" do
110
- let(:payment) { build(:payment, state: "completed") }
111
-
112
- it { is_expected.not_to be_truthy }
113
- end
114
- end
115
-
116
- describe '#can_void?' do
117
- subject { payment_source.can_void?(payment) }
118
-
119
- let(:payment_source) { described_class.new }
120
- let(:payment) { build(:payment) }
121
-
122
- let(:transaction_response) do
123
- double(:response, status: Braintree::Transaction::Status::SubmittedForSettlement)
124
- end
125
-
126
- let(:transaction_request) do
127
- double(:request, find: transaction_response)
128
- end
129
-
130
- before do
131
- allow(payment_source).to receive(:braintree_client) do
132
- double(:transaction, transaction: transaction_request)
133
- end
134
- end
135
-
136
- context 'when transaction id is not present' do
137
- let(:payment) { build(:payment, response_code: nil) }
138
-
139
- it { is_expected.to be(false) }
140
- end
141
-
142
- context 'when transaction has voidable status' do
143
- it { is_expected.to be(true) }
144
- end
145
-
146
- context 'when transaction has non voidable status' do
147
- let(:transaction_response) do
148
- double(:response, status: Braintree::Transaction::Status::Settled)
149
- end
150
-
151
- it { is_expected.to be(false) }
152
- end
153
-
154
- context 'when transaction is not found at Braintreee' do
155
- before do
156
- allow(transaction_request).to \
157
- receive(:find).and_raise(Braintree::NotFoundError)
158
- end
159
-
160
- it { is_expected.to be(false) }
161
- end
162
- end
163
-
164
- describe "#can_credit?" do
165
- subject { described_class.new.can_credit?(payment) }
166
-
167
- context "when the payment is completed" do
168
- context "when the credit allowed is 100" do
169
- let(:payment) { build(:payment, state: "completed", amount: 100) }
170
-
171
- it { is_expected.to be_truthy }
172
- end
173
-
174
- context "when the credit allowed is 0" do
175
- let(:payment) { build(:payment, state: "completed", amount: 0) }
176
-
177
- it { is_expected.not_to be_truthy }
178
- end
179
- end
180
-
181
- context "when the payment has not been completed" do
182
- let(:payment) { build(:payment, state: "checkout") }
183
-
184
- it { is_expected.not_to be_truthy }
185
- end
186
- end
187
-
188
- describe "#friendly_payment_type" do
189
- subject { described_class.new(payment_type: type).friendly_payment_type }
190
-
191
- context "when then payment type is PayPal" do
192
- let(:type) { "PayPalAccount" }
193
-
194
- it "returns the translated payment type" do
195
- expect(subject).to eq "PayPal"
196
- end
197
- end
198
-
199
- context "when the payment type is Apple Pay" do
200
- let(:type) { "ApplePayCard" }
201
-
202
- it "returns the translated payment type" do
203
- expect(subject).to eq "Apple Pay"
204
- end
205
- end
206
-
207
- context "when the payment type is Credit Card" do
208
- let(:type) { "CreditCard" }
209
-
210
- it "returns the translated payment type" do
211
- expect(subject).to eq "Credit Card"
212
- end
213
- end
214
- end
215
-
216
- describe "#apple_pay?" do
217
- subject { described_class.new(payment_type: type).apple_pay? }
218
-
219
- context "when the payment type is Apple Pay" do
220
- let(:type) { "ApplePayCard" }
221
-
222
- it { is_expected.to be true }
223
- end
224
-
225
- context "when the payment type is not Apple Pay" do
226
- let(:type) { "DogeCoin" }
227
-
228
- it { is_expected.to be false }
229
- end
230
- end
231
-
232
- describe "#paypal?" do
233
- subject { described_class.new(payment_type: type).paypal? }
234
-
235
- context "when the payment type is PayPal" do
236
- let(:type) { "PayPalAccount" }
237
-
238
- it { is_expected.to be true }
239
- end
240
-
241
- context "when the payment type is not PayPal" do
242
- let(:type) { "MonopolyMoney" }
243
-
244
- it { is_expected.to be false }
245
- end
246
- end
247
-
248
- describe "#credit_card?" do
249
- subject { described_class.new(payment_type: type).credit_card? }
250
-
251
- context "when the payment type is CreditCard" do
252
- let(:type) { "CreditCard" }
253
-
254
- it { is_expected.to be true }
255
- end
256
-
257
- context "when the payment type is not CreditCard" do
258
- let(:type) { "MonopolyMoney" }
259
-
260
- it { is_expected.to be false }
261
- end
262
- end
263
-
264
- describe "#venmo?" do
265
- subject { described_class.new(payment_type: type).venmo? }
266
-
267
- context "when the payment type is VenmoAccount" do
268
- let(:type) { "VenmoAccount" }
269
-
270
- it { is_expected.to be true }
271
- end
272
-
273
- context "when the payment type is not VenmoAccount" do
274
- let(:type) { "Swish" }
275
-
276
- it { is_expected.to be false }
277
- end
278
- end
279
-
280
- shared_context 'with unknown source token' do
281
- let(:braintree_payment_method) { double }
282
-
283
- before do
284
- allow(braintree_payment_method).to receive(:find) do
285
- raise Braintree::NotFoundError
286
- end
287
- allow(payment_source).to receive(:braintree_client) do
288
- instance_double(payment_method: braintree_payment_method)
289
- end
290
- end
291
- end
292
-
293
- shared_context 'with nil source token' do
294
- let(:braintree_payment_method) { double }
295
-
296
- before do
297
- allow(braintree_payment_method).to receive(:find) do
298
- raise ArgumentError
299
- end
300
- allow(payment_source).to receive(:braintree_client) do
301
- instance_double(payment_method: braintree_payment_method)
302
- end
303
- end
304
- end
305
-
306
- describe "#last_4" do
307
- subject { payment_source.last_4 }
308
-
309
- let(:method) { new_gateway.tap(&:save!) }
310
- let(:payment_source) { described_class.create!(payment_type: "CreditCard", payment_method: method) }
311
- let(:braintree_client) { method.braintree }
312
-
313
- context 'when token is known at braintree', vcr: {
314
- cassette_name: "source/last4",
315
- match_requests_on: [:braintree_uri]
316
- } do
317
- before do
318
- customer = braintree_client.customer.create
319
-
320
- method = braintree_client.payment_method.create({
321
- payment_method_nonce: "fake-valid-country-of-issuance-usa-nonce",
322
- customer_id: customer.customer.id
323
- })
324
-
325
- payment_source.update!(token: method.payment_method.token)
326
- end
327
-
328
- it "delegates to the braintree payment method" do
329
- method = braintree_client.payment_method.find(payment_source.token)
330
- expect(subject).to eql(method.last_4)
331
- end
332
- end
333
-
334
- context 'when the source token is not known at Braintree' do
335
- include_context 'with unknown source token'
336
-
337
- it { is_expected.to be_nil }
338
- end
339
-
340
- context 'when the source token is nil' do
341
- include_context 'with nil source token'
342
-
343
- it { is_expected.to be_nil }
344
- end
345
- end
346
-
347
- describe "#display_number" do
348
- subject { payment_source.display_number }
349
-
350
- let(:type) { nil }
351
- let(:payment_source) { described_class.new(payment_type: type) }
352
-
353
- context "when last_digits is a number" do
354
- before do
355
- allow(payment_source).to receive(:last_digits).and_return('1234')
356
- end
357
-
358
- it { is_expected.to eq 'XXXX-XXXX-XXXX-1234' }
359
- end
360
-
361
- context "when last_digits is nil" do
362
- before do
363
- allow(payment_source).to receive(:last_digits).and_return(nil)
364
- end
365
-
366
- it { is_expected.to eq 'XXXX-XXXX-XXXX-XXXX' }
367
- end
368
-
369
- context "when is a PayPal source" do
370
- let(:type) { "PayPalAccount" }
371
-
372
- before do
373
- allow(payment_source).to receive(:email).and_return('user@example.com')
374
- end
375
-
376
- it { is_expected.to eq 'user@example.com' }
377
- end
378
-
379
- context "when is a Venmo source" do
380
- let(:type) { "VenmoAccount" }
381
-
382
- before do
383
- allow(payment_source).to receive(:username).and_return('venmojoe')
384
- end
385
-
386
- it { is_expected.to eq('venmojoe') }
387
- end
388
- end
389
-
390
- describe "#card_type" do
391
- subject { payment_source.card_type }
392
-
393
- let(:method) { new_gateway.tap(&:save!) }
394
- let(:payment_source) { described_class.create!(payment_type: "CreditCard", payment_method: method) }
395
- let(:braintree_client) { method.braintree }
396
-
397
- context "when the token is known at braintree", vcr: {
398
- cassette_name: "source/card_type",
399
- match_requests_on: [:braintree_uri]
400
- } do
401
- before do
402
- customer = braintree_client.customer.create
403
-
404
- method = braintree_client.payment_method.create({
405
- payment_method_nonce: "fake-valid-country-of-issuance-usa-nonce", customer_id: customer.customer.id
406
- })
407
-
408
- payment_source.update!(token: method.payment_method.token)
409
- end
410
-
411
- it "delegates to the braintree payment method" do
412
- method = braintree_client.payment_method.find(payment_source.token)
413
- expect(subject).to eql(method.card_type)
414
- end
415
- end
416
-
417
- context 'when the source token is not known at Braintree' do
418
- include_context 'with unknown source token'
419
-
420
- it { is_expected.to be_nil }
421
- end
422
-
423
- context 'when the source token is nil' do
424
- include_context 'with nil source token'
425
-
426
- it { is_expected.to be_nil }
427
- end
428
- end
429
-
430
- describe '#display_paypal_funding_source' do
431
- let(:payment_source) { described_class.new }
432
-
433
- context 'when the EN locale exists' do
434
- it 'translates the funding source' do
435
- payment_source.paypal_funding_source = 'card'
436
-
437
- result = payment_source.display_paypal_funding_source
438
-
439
- expect(result).to eq('Credit or debit card')
440
- end
441
- end
442
-
443
- context "when the locale doesn't exist" do
444
- it 'returns the paypal_funding_source as the default' do
445
- allow(payment_source).to receive(:paypal_funding_source).and_return('non-existent')
446
-
447
- result = payment_source.display_paypal_funding_source
448
-
449
- expect(result).to eq('non-existent')
450
- end
451
- end
452
- end
453
-
454
- describe "#bin" do
455
- subject { payment_source.bin }
456
-
457
- let(:method) { new_gateway.tap(&:save!) }
458
- let(:payment_source) { described_class.create!(payment_type: "CreditCard", payment_method: method) }
459
- let(:braintree_client) { method.braintree }
460
-
461
- context "when the token is known at braintree", vcr: {
462
- cassette_name: "source/bin",
463
- match_requests_on: [:braintree_uri]
464
- } do
465
- before do
466
- customer = braintree_client.customer.create
467
-
468
- method = braintree_client.payment_method.create({
469
- payment_method_nonce: "fake-valid-country-of-issuance-usa-nonce", customer_id: customer.customer.id
470
- })
471
-
472
- payment_source.update!(token: method.payment_method.token)
473
- end
474
-
475
- it "delegates to the braintree payment method" do
476
- method = braintree_client.payment_method.find(payment_source.token)
477
- expect(subject).to eql(method.bin)
478
- end
479
- end
480
-
481
- context 'when the source token is not known at Braintree' do
482
- include_context 'with unknown source token'
483
-
484
- it { is_expected.to be_nil }
485
- end
486
-
487
- context 'when the source token is nil' do
488
- include_context 'with nil source token'
489
-
490
- it { is_expected.to be_nil }
491
- end
492
- end
493
-
494
- describe '#display_payment_type' do
495
- subject { described_class.new(payment_type: type).display_payment_type }
496
-
497
- context 'when type is CreditCard' do
498
- let(:type) { 'CreditCard' }
499
-
500
- it 'returns "Payment Type: Credit Card' do
501
- expect(subject).to eq('Payment Type: Credit Card')
502
- end
503
- end
504
-
505
- context 'when type is PayPalAccount' do
506
- let(:type) { 'PayPalAccount' }
507
-
508
- it 'returns "Payment Type: PayPal' do
509
- expect(subject).to eq('Payment Type: PayPal')
510
- end
511
- end
512
-
513
- context 'when type is VenmoAccount' do
514
- let(:type) { 'VenmoAccount' }
515
-
516
- it 'returns "Payment Type: Venmo' do
517
- expect(subject).to eq('Payment Type: Venmo')
518
- end
519
- end
520
- end
521
-
522
- describe '#reusable?' do
523
- subject { payment_source.reusable? }
524
-
525
- let(:payment_source) { described_class.new(token: token, nonce: nonce) }
526
- let(:nonce) { 'nonce67890' }
527
-
528
- context 'when source token is present' do
529
- let(:token) { 'token12345' }
530
-
531
- it { is_expected.to be_truthy }
532
- end
533
-
534
- context 'when source token is nil' do
535
- let(:token) { nil }
536
-
537
- it { is_expected.to be_falsy }
538
- end
539
- end
540
-
541
- describe "#device_data" do
542
- let(:payment_source) { build(:solidus_braintree_source) }
543
-
544
- context "when blank on validation" do
545
- before do
546
- payment_source.device_data = ""
547
- payment_source.valid?
548
- end
549
-
550
- it "is set to nil" do
551
- expect(payment_source.device_data).to be_nil
552
- end
553
- end
554
- end
555
- end