stripe_model_callbacks 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stripe_model_callbacks/factories/stripe_bank_accounts.rb +5 -0
- data/lib/stripe_model_callbacks/factories/stripe_cards.rb +7 -0
- data/lib/stripe_model_callbacks/factories/stripe_charges.rb +11 -0
- data/lib/stripe_model_callbacks/factories/stripe_coupons.rb +5 -0
- data/lib/stripe_model_callbacks/factories/stripe_customers.rb +17 -0
- data/lib/stripe_model_callbacks/factories/stripe_discounts.rb +6 -0
- data/lib/stripe_model_callbacks/factories/stripe_disputes.rb +7 -0
- data/lib/stripe_model_callbacks/factories/stripe_invoice_items.rb +11 -0
- data/lib/stripe_model_callbacks/factories/stripe_invoices.rb +16 -0
- data/lib/stripe_model_callbacks/factories/stripe_order_items.rb +8 -0
- data/lib/stripe_model_callbacks/factories/stripe_orders.rb +9 -0
- data/lib/stripe_model_callbacks/factories/stripe_payouts.rb +5 -0
- data/lib/stripe_model_callbacks/factories/stripe_plans.rb +28 -0
- data/lib/stripe_model_callbacks/factories/stripe_products.rb +5 -0
- data/lib/stripe_model_callbacks/factories/stripe_recipients.rb +5 -0
- data/lib/stripe_model_callbacks/factories/stripe_refunds.rb +9 -0
- data/lib/stripe_model_callbacks/factories/stripe_reviews.rb +6 -0
- data/lib/stripe_model_callbacks/factories/stripe_skus.rb +7 -0
- data/lib/stripe_model_callbacks/factories/stripe_sources.rb +8 -0
- data/lib/stripe_model_callbacks/factories/stripe_subscription_items.rb +19 -0
- data/lib/stripe_model_callbacks/factories/stripe_subscriptions.rb +40 -0
- data/lib/stripe_model_callbacks/factories/stripe_transfers.rb +8 -0
- data/lib/stripe_model_callbacks/factory_bot_definitions.rb +1 -1
- data/lib/stripe_model_callbacks/version.rb +1 -1
- metadata +27 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8960c2c38ee84c3e3bca2584f510517c5b2e376b644ded3f32e78e9cb8a854e
|
4
|
+
data.tar.gz: caaffd9c4bf3d43a93b6a1f0c1fc849816da7533febd828db507809c8882efcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77eb0b8e66fbeebb8b0dd1034cbd87423ab3632ac7be297704ad22ebc9fda8cdb460a53896d97e183d7c04ec48d440feb6c0b72af41e52d22c3e317295a0e3d9
|
7
|
+
data.tar.gz: 45718f0c45e6b896ee8d2e3127084adb652edb1587d0666deaf8c6c9d7829c1d7bd51498d89b7b0135af7a8c2d45338b736a90bd4e37c347e4c14ccd12d6cf2a
|
@@ -0,0 +1,17 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :stripe_customer do
|
3
|
+
sequence(:stripe_id) { |n| "customer-identifier-#{n}" }
|
4
|
+
account_balance { 0 }
|
5
|
+
currency { "usd" }
|
6
|
+
delinquent { false }
|
7
|
+
livemode { false }
|
8
|
+
|
9
|
+
trait :with_stripe_mock do
|
10
|
+
after :create do |stripe_customer|
|
11
|
+
mock_customer = Stripe::Customer.create(source: StripeMock.create_test_helper.generate_card_token)
|
12
|
+
stripe_customer.assign_from_stripe(mock_customer)
|
13
|
+
stripe_customer.save!
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :stripe_invoice_item do
|
3
|
+
sequence(:stripe_id) { |n| "stripe-invoice-item-#{n}" }
|
4
|
+
amount { Money.new(1_000, "USD") }
|
5
|
+
stripe_invoice
|
6
|
+
currency { "usd" }
|
7
|
+
discountable { false }
|
8
|
+
proration { false }
|
9
|
+
sequence(:description) { |n| "Test #{n}" }
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :stripe_invoice do
|
3
|
+
sequence(:stripe_id) { |n| "stripe-invoice-#{n}" }
|
4
|
+
amount_due_cents { 0 }
|
5
|
+
amount_due_currency { "USD" }
|
6
|
+
attempted { false }
|
7
|
+
billing { "charge_automatically" }
|
8
|
+
closed { false }
|
9
|
+
created { 2.days.ago }
|
10
|
+
currency { "usd" }
|
11
|
+
forgiven { false }
|
12
|
+
livemode { false }
|
13
|
+
paid { false }
|
14
|
+
stripe_customer
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :stripe_plan do
|
3
|
+
sequence(:stripe_id) { |n| "stripe_plan_#{n}" }
|
4
|
+
amount_cents { 10_000 }
|
5
|
+
amount_currency { "USD" }
|
6
|
+
currency { "usd" }
|
7
|
+
interval { "months" }
|
8
|
+
interval_count { 1 }
|
9
|
+
livemode { false }
|
10
|
+
stripe_product
|
11
|
+
|
12
|
+
trait :with_stripe_mock do
|
13
|
+
after :create do |stripe_plan|
|
14
|
+
mock_plan = Stripe::Plan.create(
|
15
|
+
id: stripe_plan.stripe_id,
|
16
|
+
amount: stripe_plan.amount_cents,
|
17
|
+
currency: stripe_plan.currency,
|
18
|
+
name: "No name any more - waiting for Stripe mock to be updated",
|
19
|
+
interval: stripe_plan.interval,
|
20
|
+
interval_count: stripe_plan.interval_count,
|
21
|
+
product: stripe_plan.stripe_product.stripe_id
|
22
|
+
)
|
23
|
+
stripe_plan.assign_from_stripe(mock_plan)
|
24
|
+
stripe_plan.save!
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :stripe_subscription_item do
|
3
|
+
sequence(:stripe_id) { |n| "stripe-subscription-item-#{n}" }
|
4
|
+
stripe_subscription
|
5
|
+
stripe_plan
|
6
|
+
quantity { 1 }
|
7
|
+
|
8
|
+
trait :with_stripe_mock do
|
9
|
+
after :build do |item|
|
10
|
+
mock_item = Stripe::SubscriptionItem.create(
|
11
|
+
subscription: item.stripe_subscription.stripe_id,
|
12
|
+
plan: item.stripe_plan.stripe_id,
|
13
|
+
quantity: item.quantity
|
14
|
+
)
|
15
|
+
item.assign_from_stripe(mock_item)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :stripe_subscription do
|
3
|
+
sequence(:stripe_id) { |n| "stripe-subscription-#{n}" }
|
4
|
+
billing { "charge_automatically" }
|
5
|
+
cancel_at_period_end { false }
|
6
|
+
created { Time.zone.now.beginning_of_month }
|
7
|
+
current_period_start { Time.zone.now.beginning_of_month }
|
8
|
+
current_period_end { Time.zone.now.end_of_month }
|
9
|
+
stripe_customer
|
10
|
+
livemode { false }
|
11
|
+
stripe_plan
|
12
|
+
start { 1.month.ago.beginning_of_month }
|
13
|
+
|
14
|
+
trait :active do
|
15
|
+
status { "active" }
|
16
|
+
end
|
17
|
+
|
18
|
+
trait :cancel_at_period_end do
|
19
|
+
cancel_at_period_end { true }
|
20
|
+
end
|
21
|
+
|
22
|
+
trait :with_stripe_mock do
|
23
|
+
association :stripe_customer, factory: [:stripe_customer, :with_stripe_mock]
|
24
|
+
association :stripe_plan, factory: [:stripe_plan, :with_stripe_mock]
|
25
|
+
|
26
|
+
after :create do |stripe_subscription|
|
27
|
+
cancel_at_period_end = stripe_subscription.cancel_at_period_end?
|
28
|
+
|
29
|
+
mock_subscription = Stripe::Subscription.create(
|
30
|
+
customer: stripe_subscription.stripe_customer.stripe_id,
|
31
|
+
plan: stripe_subscription.stripe_plan.stripe_id
|
32
|
+
)
|
33
|
+
stripe_subscription.assign_from_stripe(mock_subscription)
|
34
|
+
stripe_subscription.save!
|
35
|
+
|
36
|
+
stripe_subscription.cancel!(at_period_end: true) if cancel_at_period_end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe_model_callbacks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: stripe-ruby-mock
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 2.5.8
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 2.5.8
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: stripe_event
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -197,6 +197,28 @@ files:
|
|
197
197
|
- lib/stripe_model_callbacks/configuration.rb
|
198
198
|
- lib/stripe_model_callbacks/engine.rb
|
199
199
|
- lib/stripe_model_callbacks/event_mocker.rb
|
200
|
+
- lib/stripe_model_callbacks/factories/stripe_bank_accounts.rb
|
201
|
+
- lib/stripe_model_callbacks/factories/stripe_cards.rb
|
202
|
+
- lib/stripe_model_callbacks/factories/stripe_charges.rb
|
203
|
+
- lib/stripe_model_callbacks/factories/stripe_coupons.rb
|
204
|
+
- lib/stripe_model_callbacks/factories/stripe_customers.rb
|
205
|
+
- lib/stripe_model_callbacks/factories/stripe_discounts.rb
|
206
|
+
- lib/stripe_model_callbacks/factories/stripe_disputes.rb
|
207
|
+
- lib/stripe_model_callbacks/factories/stripe_invoice_items.rb
|
208
|
+
- lib/stripe_model_callbacks/factories/stripe_invoices.rb
|
209
|
+
- lib/stripe_model_callbacks/factories/stripe_order_items.rb
|
210
|
+
- lib/stripe_model_callbacks/factories/stripe_orders.rb
|
211
|
+
- lib/stripe_model_callbacks/factories/stripe_payouts.rb
|
212
|
+
- lib/stripe_model_callbacks/factories/stripe_plans.rb
|
213
|
+
- lib/stripe_model_callbacks/factories/stripe_products.rb
|
214
|
+
- lib/stripe_model_callbacks/factories/stripe_recipients.rb
|
215
|
+
- lib/stripe_model_callbacks/factories/stripe_refunds.rb
|
216
|
+
- lib/stripe_model_callbacks/factories/stripe_reviews.rb
|
217
|
+
- lib/stripe_model_callbacks/factories/stripe_skus.rb
|
218
|
+
- lib/stripe_model_callbacks/factories/stripe_sources.rb
|
219
|
+
- lib/stripe_model_callbacks/factories/stripe_subscription_items.rb
|
220
|
+
- lib/stripe_model_callbacks/factories/stripe_subscriptions.rb
|
221
|
+
- lib/stripe_model_callbacks/factories/stripe_transfers.rb
|
200
222
|
- lib/stripe_model_callbacks/factory_bot_definitions.rb
|
201
223
|
- lib/stripe_model_callbacks/models/stripe_bank_account.rb
|
202
224
|
- lib/stripe_model_callbacks/models/stripe_card.rb
|