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

Commit

Permalink
Don't return cancelled payment methods
Browse files Browse the repository at this point in the history
  • Loading branch information
osahyoun committed Jan 16, 2017
1 parent 3563fae commit 7e57b9a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/payment_method_fetcher.rb
Expand Up @@ -35,7 +35,7 @@ def empty_filter?
def payment_methods
return @payment_methods if @payment_methods

query = @member.customer.payment_methods.stored
query = @member.customer.payment_methods.stored.active
query = query.where(token: @filter) unless @filter.nil?

@payment_methods = query
Expand Down
14 changes: 14 additions & 0 deletions spec/services/payment_method_fetcher_spec.rb
Expand Up @@ -46,4 +46,18 @@
expect(subject.fetch).to match_array([])
end
end

context 'with cancelled payment method' do
subject { PaymentMethodFetcher.new(member) }

before do
method_a.update(cancelled_at: Time.now)
end

it 'only fetches active methods' do
expected = [method_b].map(&formatter)

expect(subject.fetch).to match_array(expected)
end
end
end

0 comments on commit 7e57b9a

Please sign in to comment.