Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
knowmalaria
stripe-ruby-mock
Commits
be47b34b
Commit
be47b34b
authored
Dec 03, 2015
by
Benjie Gillam
Browse files
Restore total_count functionality.
parent
454a71c7
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/stripe_mock/request_handlers/customers.rb
View file @
be47b34b
...
...
@@ -62,13 +62,12 @@ module StripeMock
# Delete those params if their value is nil. Workaround of the problematic way Stripe serialize objects
params
.
delete
(
:sources
)
if
params
[
:sources
]
&&
params
[
:sources
][
:data
].
nil?
params
.
delete
(
:subscriptions
)
if
params
[
:subscriptions
]
&&
params
[
:subscriptions
][
:data
].
nil?
# Delete those params if their values aren't valid. Workaround of the problematic way Stripe serialize objects
if
params
[
:sources
]
&&
!
params
[
:sources
][
:data
].
nil?
# Copy old sources over empty objects
params
[
:sources
][
:data
].
collect!
.
with_index
{
|
v
,
i
|
!
v
[
:type
]
?
cus
[
:sources
][
:data
][
i
].
clone
:
v
}
params
.
delete
(
:sources
)
unless
params
[
:sources
][
:data
].
any?
{
|
v
|
!!
v
[
:type
]}
end
if
params
[
:subscriptions
]
&&
!
params
[
:subscriptions
][
:data
].
nil?
# Copy old subscriptions over empty objects
params
[
:subscriptions
][
:data
].
collect!
.
with_index
{
|
v
,
i
|
!
v
[
:type
]
?
cus
[
:subscriptions
][
:data
][
i
].
clone
:
v
}
params
.
delete
(
:subscriptions
)
unless
params
[
:subscriptions
][
:data
].
any?
{
|
v
|
!!
v
[
:type
]}
end
cus
.
merge!
(
params
)
...
...
spec/shared_stripe_examples/customer_examples.rb
View file @
be47b34b
...
...
@@ -322,10 +322,12 @@ shared_examples 'Customer API' do
original
=
Stripe
::
Customer
.
create
(
source:
gen_card_tk
)
card
=
original
.
sources
.
data
.
first
card_id
=
card
.
id
expect
(
original
.
sources
.
total_count
).
to
eq
(
1
)
original
.
save
expect
(
original
.
sources
.
data
.
first
.
id
).
to
eq
(
card_id
)
expect
(
original
.
sources
.
total_count
).
to
eq
(
1
)
end
it
"still has subscriptions after save when subscriptions unchanged"
do
...
...
@@ -333,10 +335,12 @@ shared_examples 'Customer API' do
original
=
Stripe
::
Customer
.
create
(
source:
gen_card_tk
,
plan:
'silver'
)
subscription
=
original
.
subscriptions
.
data
.
first
subscription_id
=
subscription
.
id
expect
(
original
.
subscriptions
.
total_count
).
to
eq
(
1
)
original
.
save
expect
(
original
.
subscriptions
.
data
.
first
.
id
).
to
eq
(
subscription_id
)
expect
(
original
.
subscriptions
.
total_count
).
to
eq
(
1
)
end
it
"deletes a customer"
do
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment