-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add make_default method on AddPaymentSourcesToWallet class
Move the logic to make the last payment source as default outside the add_to_wallet method to take advantage if someone wants to change only the make default behavior.
- Loading branch information
1 parent
3ceec32
commit 27fb811
Showing
2 changed files
with
25 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
core/spec/models/spree/wallet/add_payment_sources_to_wallet_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Spree::Wallet::AddPaymentSourcesToWallet, type: :model do | ||
let(:order) { create(:order_ready_to_complete) } | ||
|
||
describe '#add_to_wallet' do | ||
subject { described_class.new(order) } | ||
|
||
it 'saves the payment source' do | ||
expect { subject.add_to_wallet }.to change { | ||
order.user.wallet.wallet_payment_sources.count | ||
}.by(1) | ||
end | ||
end | ||
end |