openpay 1.0.10 → 2.0.0b
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.
- checksums.yaml +4 -4
- data/.travis.yml +7 -1
- data/Gemfile +2 -2
- data/README.md +2 -2
- data/Rakefile +2 -1
- data/lib/version.rb +1 -1
- data/openpay.gemspec +6 -6
- data/test/Factories.rb +16 -16
- data/test/spec/bankaccounts_spec.rb +19 -18
- data/test/spec/cards_spec.rb +35 -37
- data/test/spec/charges_spec.rb +44 -67
- data/test/spec/customers_spec.rb +11 -12
- data/test/spec/exceptions_spec.rb +2 -20
- data/test/spec/fees_spec.rb +22 -18
- data/test/spec/openpayresource_spec.rb +2 -2
- data/test/spec/payouts_spec.rb +39 -44
- data/test/spec/plans_spec.rb +14 -10
- data/test/spec/subscriptions_spec.rb +37 -36
- data/test/spec/transfers_spec.rb +35 -31
- data/test/spec_helper.rb +7 -1
- metadata +50 -51
- data/test/spec/webhook_spec.rb +0 -104
@@ -23,7 +23,7 @@ describe 'OpenPayResource' do
|
|
23
23
|
|
24
24
|
|
25
25
|
it 'converts a ruby hash into a json string' do
|
26
|
-
card_hash =
|
26
|
+
card_hash = FactoryBot.build(:valid_card, holder_name: 'Juan')
|
27
27
|
json=@cards.hash2json(card_hash)
|
28
28
|
expect(json).to have_json_path('holder_name')
|
29
29
|
expect(json).to have_json_path('expiration_year')
|
@@ -39,7 +39,7 @@ describe 'OpenPayResource' do
|
|
39
39
|
|
40
40
|
|
41
41
|
it 'converts json into a ruby hash' do
|
42
|
-
card_hash =
|
42
|
+
card_hash = FactoryBot.build(:valid_card, holder_name: 'Pepe')
|
43
43
|
json=@cards.hash2json(card_hash)
|
44
44
|
jash=@cards.json2hash(json)
|
45
45
|
expect(jash).to be_a Hash
|
data/test/spec/payouts_spec.rb
CHANGED
@@ -30,42 +30,40 @@ describe Payouts do
|
|
30
30
|
|
31
31
|
describe '.create' do
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
pending
|
33
|
+
skip 'creates a merchant payout' do
|
34
|
+
#pending("is a pending example")
|
36
35
|
#create merchant card
|
37
|
-
card_hash =
|
36
|
+
card_hash = FactoryBot.build(:valid_card)
|
38
37
|
card = @cards.create(card_hash)
|
39
38
|
|
40
39
|
#create charge
|
41
|
-
charge_hash=
|
40
|
+
charge_hash=FactoryBot.build(:card_charge, source_id: card['id'], order_id: card['id'])
|
42
41
|
charge=@charges.create(charge_hash)
|
43
42
|
|
44
|
-
payout_hash=
|
43
|
+
payout_hash=FactoryBot.build(:payout_card, destination_id: card['id'], amount: 100)
|
45
44
|
|
46
45
|
payout=@payouts.create(payout_hash)
|
47
46
|
expect(@payouts.get(payout['id'])['amount']).to be_within(0.1).of(100)
|
48
47
|
|
49
48
|
@cards.delete(card['id'])
|
50
|
-
|
51
49
|
end
|
52
|
-
|
53
|
-
|
50
|
+
|
51
|
+
skip 'creates a customer payout using a card' do
|
54
52
|
#We need to charge 1st into the card we are going to use
|
55
53
|
|
56
54
|
#create new customer
|
57
|
-
customer_hash=
|
55
|
+
customer_hash=FactoryBot.build(:customer)
|
58
56
|
customer=@customers.create(customer_hash)
|
59
57
|
|
60
58
|
#create new customer card
|
61
|
-
card_hash=
|
59
|
+
card_hash=FactoryBot.build(:valid_card)
|
62
60
|
card=@cards.create(card_hash, customer['id'])
|
63
61
|
|
64
62
|
#create charge
|
65
|
-
charge_hash=
|
63
|
+
charge_hash=FactoryBot.build(:card_charge, source_id: card['id'], order_id: card['id'])
|
66
64
|
charge=@charges.create(charge_hash, customer['id'])
|
67
65
|
|
68
|
-
payout_hash=
|
66
|
+
payout_hash=FactoryBot.build(:payout_card, destination_id: card['id'], amount: 400)
|
69
67
|
|
70
68
|
payout=@payouts.create(payout_hash, customer['id'])
|
71
69
|
expect(@payouts.get(payout['id'], customer['id'])['amount']).to be_within(0.1).of(400)
|
@@ -75,26 +73,25 @@ describe Payouts do
|
|
75
73
|
@bank_accounts.delete_all(customer['id'])
|
76
74
|
|
77
75
|
end
|
78
|
-
|
79
|
-
it 'creates a customer payout using a bank account' do
|
76
|
+
skip 'creates a customer payout using a bank account' do
|
80
77
|
|
81
78
|
#create new customer
|
82
|
-
customer_hash=
|
79
|
+
customer_hash=FactoryBot.build(:customer)
|
83
80
|
customer=@customers.create(customer_hash)
|
84
81
|
|
85
82
|
#create new customer card
|
86
|
-
card_hash=
|
83
|
+
card_hash=FactoryBot.build(:valid_card)
|
87
84
|
card=@cards.create(card_hash, customer['id'])
|
88
85
|
|
89
86
|
#create new customer bank account
|
90
|
-
account_hash=
|
87
|
+
account_hash=FactoryBot.build(:bank_account)
|
91
88
|
account=@bank_accounts.create(account_hash, customer['id'])
|
92
89
|
|
93
90
|
#create charge
|
94
|
-
charge_hash=
|
91
|
+
charge_hash=FactoryBot.build(:card_charge, source_id: card['id'], order_id: card['id'])
|
95
92
|
charge=@charges.create(charge_hash, customer['id'])
|
96
93
|
|
97
|
-
payout_hash=
|
94
|
+
payout_hash=FactoryBot.build(:payout_card, destination_id: account['id'], amount: 400)
|
98
95
|
|
99
96
|
payout=@payouts.create(payout_hash, customer['id'])
|
100
97
|
expect(@payouts.get(payout['id'], customer['id'])['amount']).to be_within(0.1).of(400)
|
@@ -108,30 +105,27 @@ describe Payouts do
|
|
108
105
|
|
109
106
|
describe '.get' do
|
110
107
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
payout_hash= FactoryGirl.build(:payout_card, destination_id: 'bxz8ixftukkkjnrnypzb', amount: 10)
|
115
|
-
|
108
|
+
skip 'gets a merchant payout' do
|
109
|
+
#pending("is a pending example")
|
110
|
+
payout_hash= FactoryBot.build(:payout_card, destination_id: 'bxz8ixftukkkjnrnypzb', amount: 10)
|
116
111
|
payout=@payouts.create(payout_hash)
|
117
112
|
expect(@payouts.get(payout['id'])['amount']).to be_within(0.1).of(10)
|
118
|
-
|
119
113
|
end
|
120
114
|
|
121
|
-
|
115
|
+
skip 'gets a customer payout' do
|
122
116
|
#create new customer
|
123
|
-
customer_hash=
|
117
|
+
customer_hash= FactoryBot.build(:customer)
|
124
118
|
customer=@customers.create(customer_hash)
|
125
119
|
|
126
120
|
#create new customer card
|
127
|
-
card_hash=
|
121
|
+
card_hash=FactoryBot.build(:valid_card)
|
128
122
|
card=@cards.create(card_hash, customer['id'])
|
129
123
|
|
130
124
|
#create charge
|
131
|
-
charge_hash=
|
125
|
+
charge_hash=FactoryBot.build(:card_charge, source_id: card['id'], order_id: card['id'])
|
132
126
|
charge=@charges.create(charge_hash, customer['id'])
|
133
127
|
|
134
|
-
payout_hash=
|
128
|
+
payout_hash= FactoryBot.build(:payout_card, destination_id: card['id'], amount: 40)
|
135
129
|
|
136
130
|
payout=@payouts.create(payout_hash, customer['id'])
|
137
131
|
|
@@ -147,26 +141,26 @@ describe Payouts do
|
|
147
141
|
|
148
142
|
describe '.all' do
|
149
143
|
|
150
|
-
|
151
|
-
pending
|
144
|
+
skip 'all merchant payouts' do
|
145
|
+
#pending("is a pending example")
|
152
146
|
expect(@payouts.all.size).to be_a Integer
|
153
147
|
expect(@payouts.all.last['transaction_type']).to match 'payout'
|
154
148
|
end
|
155
149
|
|
156
|
-
|
150
|
+
skip 'all customer payouts' do
|
157
151
|
#create new customer
|
158
|
-
customer_hash=
|
152
|
+
customer_hash= FactoryBot.build(:customer)
|
159
153
|
customer=@customers.create(customer_hash)
|
160
154
|
|
161
155
|
#create new customer card
|
162
|
-
card_hash=
|
156
|
+
card_hash=FactoryBot.build(:valid_card)
|
163
157
|
card=@cards.create(card_hash, customer['id'])
|
164
158
|
|
165
159
|
#create charge
|
166
|
-
charge_hash=
|
160
|
+
charge_hash=FactoryBot.build(:card_charge, source_id: card['id'], order_id: card['id'])
|
167
161
|
charge=@charges.create(charge_hash, customer['id'])
|
168
162
|
|
169
|
-
payout_hash=
|
163
|
+
payout_hash= FactoryBot.build(:payout_card, destination_id: card['id'], amount: 40)
|
170
164
|
|
171
165
|
payout=@payouts.create(payout_hash, customer['id'])
|
172
166
|
|
@@ -185,21 +179,21 @@ describe Payouts do
|
|
185
179
|
|
186
180
|
describe '.list' do
|
187
181
|
|
188
|
-
|
182
|
+
skip 'list payouts given the filter' do
|
189
183
|
|
190
184
|
#create new customer
|
191
|
-
customer_hash=
|
185
|
+
customer_hash= FactoryBot.build(:customer)
|
192
186
|
customer=@customers.create(customer_hash)
|
193
187
|
|
194
188
|
#create new customer card
|
195
|
-
card_hash=
|
189
|
+
card_hash=FactoryBot.build(:valid_card)
|
196
190
|
card=@cards.create(card_hash, customer['id'])
|
197
191
|
|
198
192
|
#create charge
|
199
|
-
charge_hash=
|
193
|
+
charge_hash=FactoryBot.build(:card_charge, source_id: card['id'], order_id: card['id'])
|
200
194
|
charge=@charges.create(charge_hash, customer['id'])
|
201
195
|
|
202
|
-
payout_hash=
|
196
|
+
payout_hash= FactoryBot.build(:payout_card, destination_id: card['id'], amount: 40)
|
203
197
|
|
204
198
|
payout1=@payouts.create(payout_hash, customer['id'])
|
205
199
|
payout2=@payouts.create(payout_hash, customer['id'])
|
@@ -226,7 +220,8 @@ describe Payouts do
|
|
226
220
|
end
|
227
221
|
end
|
228
222
|
|
229
|
-
|
223
|
+
#revisar este test
|
224
|
+
skip 'iterates over a given customer payouts' do
|
230
225
|
a_customer=@customers.all.last
|
231
226
|
@payouts.each(a_customer['id']) do |pay|
|
232
227
|
expect(@payouts.get(pay['id'], a_customer['id'])['transaction_type']).to match 'payout'
|
data/test/spec/plans_spec.rb
CHANGED
@@ -17,10 +17,14 @@ describe Plans do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
|
20
|
+
=begin
|
21
|
+
|
20
22
|
after(:all) do
|
21
23
|
@plans.delete_all
|
22
24
|
end
|
23
25
|
|
26
|
+
=end
|
27
|
+
|
24
28
|
it 'has all required methods' do
|
25
29
|
%w(all each create get list delete).each do |meth|
|
26
30
|
expect(@plans).to respond_to(meth)
|
@@ -31,7 +35,7 @@ describe Plans do
|
|
31
35
|
|
32
36
|
it 'creates a merchant plan' do
|
33
37
|
|
34
|
-
plan_hash=
|
38
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5)
|
35
39
|
plan=@plans.create(plan_hash)
|
36
40
|
|
37
41
|
#validates
|
@@ -49,7 +53,7 @@ describe Plans do
|
|
49
53
|
it 'gets a merchant plan' do
|
50
54
|
|
51
55
|
#creates a plan
|
52
|
-
plan_hash=
|
56
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
53
57
|
plan=@plans.create(plan_hash)
|
54
58
|
|
55
59
|
#validates
|
@@ -83,7 +87,7 @@ describe Plans do
|
|
83
87
|
describe '.list' do
|
84
88
|
it 'list all plans given the filter' do
|
85
89
|
#creates a plan
|
86
|
-
plan_hash=
|
90
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
87
91
|
plan=@plans.create(plan_hash)
|
88
92
|
|
89
93
|
search_params = OpenpayUtils::SearchParams.new
|
@@ -100,11 +104,11 @@ describe Plans do
|
|
100
104
|
|
101
105
|
it 'updates an existing customer plan' do
|
102
106
|
#creates a plan
|
103
|
-
plan_hash=
|
107
|
+
plan_hash= FactoryBot.build(:plan, trial_days: 10)
|
104
108
|
plan=@plans.create(plan_hash)
|
105
109
|
|
106
110
|
expect(plan['trial_days']).to be 10
|
107
|
-
plan_hash=
|
111
|
+
plan_hash= FactoryBot.build(:plan, trial_days: 100)
|
108
112
|
plan=@plans.update(plan_hash, plan['id'])
|
109
113
|
expect(plan['trial_days']).to be 100
|
110
114
|
|
@@ -114,7 +118,7 @@ describe Plans do
|
|
114
118
|
|
115
119
|
it 'fails to update an non existing customer plan' do
|
116
120
|
|
117
|
-
plan_hash=
|
121
|
+
plan_hash= FactoryBot.build(:plan, trial_days: 100)
|
118
122
|
|
119
123
|
#validates
|
120
124
|
expect { @plans.update(plan_hash, '111111') }.to raise_exception RestClient::ResourceNotFound
|
@@ -122,26 +126,26 @@ describe Plans do
|
|
122
126
|
@plans.update(plan_hash, '111111')
|
123
127
|
rescue RestClient::ResourceNotFound => e
|
124
128
|
expect(e.http_body).to be_a String
|
125
|
-
expect(e.message).to
|
129
|
+
expect(e.message).to include("404")
|
126
130
|
end
|
127
131
|
|
128
132
|
end
|
129
133
|
|
130
134
|
end
|
131
135
|
|
132
|
-
|
136
|
+
skip '.each' do
|
133
137
|
|
134
138
|
it 'iterates over all customer plans' do
|
135
139
|
|
136
140
|
#creates a plan
|
137
|
-
plan_hash=
|
141
|
+
plan_hash= FactoryBot.build(:plan, trial_days: 30)
|
138
142
|
plan=@plans.create(plan_hash)
|
139
143
|
plan1=@plans.create(plan_hash)
|
140
144
|
plan2=@plans.create(plan_hash)
|
141
145
|
|
142
146
|
expect(@plans.all.size).to be_a Integer
|
143
147
|
@plans.each do |plan|
|
144
|
-
expect(plan['name']).to match '
|
148
|
+
expect(plan['name']).to match 'TODO INCLUIDO'
|
145
149
|
@plans.delete(plan['id'])
|
146
150
|
end
|
147
151
|
|
@@ -31,19 +31,19 @@ describe Subscriptions do
|
|
31
31
|
it 'creates a subscription' do
|
32
32
|
|
33
33
|
#creates a customer
|
34
|
-
customer_hash=
|
34
|
+
customer_hash=FactoryBot.build(:customer)
|
35
35
|
customer=@customers.create(customer_hash)
|
36
36
|
|
37
37
|
#creates a customer card
|
38
|
-
card_hash=
|
38
|
+
card_hash=FactoryBot.build(:valid_card)
|
39
39
|
card=@cards.create(card_hash, customer['id'])
|
40
40
|
|
41
41
|
#creates a plan
|
42
|
-
plan_hash=
|
42
|
+
plan_hash=FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
43
43
|
plan=@plans.create(plan_hash)
|
44
44
|
|
45
45
|
#creates subscription
|
46
|
-
subscription_hash=
|
46
|
+
subscription_hash=FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
47
47
|
subscription=@subscriptions.create(subscription_hash, customer['id'])
|
48
48
|
|
49
49
|
#performs check
|
@@ -62,19 +62,19 @@ describe Subscriptions do
|
|
62
62
|
it 'gets customer subscriptions' do
|
63
63
|
|
64
64
|
#creates a customer
|
65
|
-
customer_hash=
|
65
|
+
customer_hash=FactoryBot.build(:customer)
|
66
66
|
customer=@customers.create(customer_hash)
|
67
67
|
|
68
68
|
#creates a customer card
|
69
|
-
card_hash=
|
69
|
+
card_hash=FactoryBot.build(:valid_card)
|
70
70
|
card=@cards.create(card_hash, customer['id'])
|
71
71
|
|
72
72
|
#creates a plan
|
73
|
-
plan_hash=
|
73
|
+
plan_hash=FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
74
74
|
plan=@plans.create(plan_hash)
|
75
75
|
|
76
76
|
#creates subscription
|
77
|
-
subscription_hash=
|
77
|
+
subscription_hash=FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
78
78
|
subscription=@subscriptions.create(subscription_hash, customer['id'])
|
79
79
|
|
80
80
|
#get customer subscription
|
@@ -94,20 +94,22 @@ describe Subscriptions do
|
|
94
94
|
|
95
95
|
it 'updates customer subscription' do
|
96
96
|
|
97
|
+
time = Time.now + (60*60*24*2);
|
98
|
+
time = time.strftime("%Y-%m-%d")
|
97
99
|
#creates a customer
|
98
|
-
customer_hash=
|
100
|
+
customer_hash=FactoryBot.build(:customer)
|
99
101
|
customer=@customers.create(customer_hash)
|
100
102
|
|
101
103
|
#creates a customer card
|
102
|
-
card_hash=
|
104
|
+
card_hash=FactoryBot.build(:valid_card)
|
103
105
|
card=@cards.create(card_hash, customer['id'])
|
104
106
|
|
105
107
|
#creates a plan
|
106
|
-
plan_hash=
|
108
|
+
plan_hash=FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
107
109
|
plan=@plans.create(plan_hash)
|
108
110
|
|
109
111
|
#creates subscription
|
110
|
-
subscription_hash=
|
112
|
+
subscription_hash=FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
111
113
|
subscription=@subscriptions.create(subscription_hash, customer['id'])
|
112
114
|
|
113
115
|
#get customer subscription
|
@@ -115,11 +117,10 @@ describe Subscriptions do
|
|
115
117
|
|
116
118
|
#performs check
|
117
119
|
expect(stored_s['status']).to match 'trial'
|
118
|
-
|
119
|
-
|
120
|
-
|
120
|
+
subscription_update_hash={ trial_end_date: time }
|
121
|
+
sleep(20)
|
121
122
|
stored_s=@subscriptions.update(subscription['id'], customer['id'], subscription_update_hash)
|
122
|
-
expect(stored_s['trial_end_date']).to eq
|
123
|
+
expect(stored_s['trial_end_date']).to eq time
|
123
124
|
|
124
125
|
#cleanup
|
125
126
|
@subscriptions.delete(subscription['id'], customer['id'])
|
@@ -133,19 +134,19 @@ describe Subscriptions do
|
|
133
134
|
it 'returns all subscriptions for a given customer' do
|
134
135
|
|
135
136
|
#creates a customer
|
136
|
-
customer_hash=
|
137
|
+
customer_hash= FactoryBot.build(:customer)
|
137
138
|
customer=@customers.create(customer_hash)
|
138
139
|
|
139
140
|
#creates a customer card
|
140
|
-
card_hash=
|
141
|
+
card_hash= FactoryBot.build(:valid_card)
|
141
142
|
card=@cards.create(card_hash, customer['id'])
|
142
143
|
|
143
144
|
#creates a plan
|
144
|
-
plan_hash=
|
145
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
145
146
|
plan=@plans.create(plan_hash)
|
146
147
|
|
147
148
|
#creates subscription
|
148
|
-
subscription_hash=
|
149
|
+
subscription_hash= FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
149
150
|
expect(@subscriptions.all(customer['id']).size).to be 0
|
150
151
|
subscription=@subscriptions.create(subscription_hash, customer['id'])
|
151
152
|
|
@@ -163,19 +164,19 @@ describe Subscriptions do
|
|
163
164
|
|
164
165
|
it 'list subscriptions based on given filter' do
|
165
166
|
#creates a customer
|
166
|
-
customer_hash=
|
167
|
+
customer_hash= FactoryBot.build(:customer)
|
167
168
|
customer=@customers.create(customer_hash)
|
168
169
|
|
169
170
|
#creates a customer card
|
170
|
-
card_hash=
|
171
|
+
card_hash= FactoryBot.build(:valid_card)
|
171
172
|
card=@cards.create(card_hash, customer['id'])
|
172
173
|
|
173
174
|
#creates a plan
|
174
|
-
plan_hash=
|
175
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
175
176
|
plan=@plans.create(plan_hash)
|
176
177
|
|
177
178
|
#creates subscription
|
178
|
-
subscription_hash=
|
179
|
+
subscription_hash= FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
179
180
|
expect(@subscriptions.all(customer['id']).size).to be 0
|
180
181
|
subscription1=@subscriptions.create(subscription_hash, customer['id'])
|
181
182
|
subscription2=@subscriptions.create(subscription_hash, customer['id'])
|
@@ -200,19 +201,19 @@ describe Subscriptions do
|
|
200
201
|
it 'iterates over all subscriptions for a given customer' do
|
201
202
|
|
202
203
|
#creates a customer
|
203
|
-
customer_hash=
|
204
|
+
customer_hash= FactoryBot.build(:customer)
|
204
205
|
customer=@customers.create(customer_hash)
|
205
206
|
|
206
207
|
#creates a customer card
|
207
|
-
card_hash=
|
208
|
+
card_hash= FactoryBot.build(:valid_card)
|
208
209
|
card=@cards.create(card_hash, customer['id'])
|
209
210
|
|
210
211
|
#creates a plan
|
211
|
-
plan_hash=
|
212
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
212
213
|
plan=@plans.create(plan_hash)
|
213
214
|
|
214
215
|
#creates subscription
|
215
|
-
subscription_hash=
|
216
|
+
subscription_hash= FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
216
217
|
expect(@subscriptions.all(customer['id']).size).to be 0
|
217
218
|
@subscriptions.create(subscription_hash, customer['id'])
|
218
219
|
|
@@ -233,19 +234,19 @@ describe Subscriptions do
|
|
233
234
|
it 'deletes an existing subscription for a given customer' do
|
234
235
|
|
235
236
|
#creates a customer
|
236
|
-
customer_hash=
|
237
|
+
customer_hash= FactoryBot.build(:customer)
|
237
238
|
customer=@customers.create(customer_hash)
|
238
239
|
|
239
240
|
#creates a customer card
|
240
|
-
card_hash=
|
241
|
+
card_hash= FactoryBot.build(:valid_card)
|
241
242
|
card=@cards.create(card_hash, customer['id'])
|
242
243
|
|
243
244
|
#creates a plan
|
244
|
-
plan_hash=
|
245
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
245
246
|
plan=@plans.create(plan_hash)
|
246
247
|
|
247
248
|
#creates subscription
|
248
|
-
subscription_hash=
|
249
|
+
subscription_hash= FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
249
250
|
expect(@subscriptions.all(customer['id']).size).to be 0
|
250
251
|
subscription=@subscriptions.create(subscription_hash, customer['id'])
|
251
252
|
|
@@ -264,19 +265,19 @@ describe Subscriptions do
|
|
264
265
|
it 'deletes all existing subscription for a given customer' do
|
265
266
|
|
266
267
|
#creates a customer
|
267
|
-
customer_hash=
|
268
|
+
customer_hash= FactoryBot.build(:customer)
|
268
269
|
customer=@customers.create(customer_hash)
|
269
270
|
|
270
271
|
#creates a customer card
|
271
|
-
card_hash=
|
272
|
+
card_hash= FactoryBot.build(:valid_card)
|
272
273
|
card=@cards.create(card_hash, customer['id'])
|
273
274
|
|
274
275
|
#creates a plan
|
275
|
-
plan_hash=
|
276
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
276
277
|
plan=@plans.create(plan_hash)
|
277
278
|
|
278
279
|
#creates subscriptions
|
279
|
-
subscription_hash=
|
280
|
+
subscription_hash= FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
280
281
|
expect(@subscriptions.all(customer['id']).size).to be 0
|
281
282
|
@subscriptions.create(subscription_hash, customer['id'])
|
282
283
|
@subscriptions.create(subscription_hash, customer['id'])
|