ashmont 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/ashmont/customer.rb +17 -0
- data/lib/ashmont/version.rb +1 -1
- data/spec/ashmont/customer_spec.rb +23 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f6ca58a042c682e1897e0c7036a559cba64d843
|
4
|
+
data.tar.gz: 43f0ec1f2702b8f5878e7da24744cba7b047440d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01c453adb9c23b7f08f46e5bcdfc65b09305b1992b22ff587b36ff9dc9834177db83e17490571352dcd381f62ce8c2f16926c87dab083cd7123d43b89705db52
|
7
|
+
data.tar.gz: cc9d490e0004ae7fce9d7e12f7a4149d8d3238ca4e65e37f3893de43e86ff267e227c32c81c0cccdb041219a7864b514d7c65a6c92ec03fee6bcc9bd0c771faa
|
data/CHANGELOG.md
CHANGED
data/lib/ashmont/customer.rb
CHANGED
@@ -35,6 +35,23 @@ module Ashmont
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
def primary_payment_method
|
39
|
+
#currently, usually there is only one payment method, paypal or credit_card
|
40
|
+
payment_methods = { credit_cards.count => :credit_cards,
|
41
|
+
paypal_accounts.count => :paypal_accounts }
|
42
|
+
chosen_method = (payment_methods[payment_methods.keys.max])
|
43
|
+
remote_customer.send(chosen_method)
|
44
|
+
end
|
45
|
+
|
46
|
+
def primary_payment_account
|
47
|
+
if persisted?
|
48
|
+
primary_payment_method[]
|
49
|
+
else
|
50
|
+
[]
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
38
55
|
def has_billing_info?
|
39
56
|
credit_card.present?
|
40
57
|
end
|
data/lib/ashmont/version.rb
CHANGED
@@ -2,6 +2,29 @@ require 'spec_helper'
|
|
2
2
|
require 'ashmont/customer'
|
3
3
|
|
4
4
|
describe Ashmont::Customer do
|
5
|
+
|
6
|
+
it 'chooses paypal_accounts as the primary_payment_method when the customer does' do
|
7
|
+
token = "xyz"
|
8
|
+
remote_customer = stub("customer", :paypal_accounts => ["first", "second"], :credit_cards => [])
|
9
|
+
Braintree::Customer.stubs(:find => remote_customer)
|
10
|
+
|
11
|
+
result = Ashmont::Customer.new(token).primary_payment_method
|
12
|
+
|
13
|
+
expect(Braintree::Customer).to have_received(:find).with(token)
|
14
|
+
expect(result).to eq(["first", "second"])
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'chooses credit_cards as the primary_payment_method when the customer does' do
|
18
|
+
token = "xyz"
|
19
|
+
remote_customer = stub("customer", :paypal_accounts => [], :credit_cards => ["first", "second"])
|
20
|
+
Braintree::Customer.stubs(:find => remote_customer)
|
21
|
+
|
22
|
+
result = Ashmont::Customer.new(token).primary_payment_method
|
23
|
+
|
24
|
+
expect(Braintree::Customer).to have_received(:find).with(token)
|
25
|
+
expect(result).to eq(["first", "second"])
|
26
|
+
end
|
27
|
+
|
5
28
|
it "returns all paypal accounts" do
|
6
29
|
token = "xyz"
|
7
30
|
remote_customer = stub("customer", :paypal_accounts => ["first", "second"])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ashmont
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thoughtbot
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-04-
|
12
|
+
date: 2017-04-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: braintree
|