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.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/lib/stripe_model_callbacks/factories/stripe_bank_accounts.rb +5 -0
  3. data/lib/stripe_model_callbacks/factories/stripe_cards.rb +7 -0
  4. data/lib/stripe_model_callbacks/factories/stripe_charges.rb +11 -0
  5. data/lib/stripe_model_callbacks/factories/stripe_coupons.rb +5 -0
  6. data/lib/stripe_model_callbacks/factories/stripe_customers.rb +17 -0
  7. data/lib/stripe_model_callbacks/factories/stripe_discounts.rb +6 -0
  8. data/lib/stripe_model_callbacks/factories/stripe_disputes.rb +7 -0
  9. data/lib/stripe_model_callbacks/factories/stripe_invoice_items.rb +11 -0
  10. data/lib/stripe_model_callbacks/factories/stripe_invoices.rb +16 -0
  11. data/lib/stripe_model_callbacks/factories/stripe_order_items.rb +8 -0
  12. data/lib/stripe_model_callbacks/factories/stripe_orders.rb +9 -0
  13. data/lib/stripe_model_callbacks/factories/stripe_payouts.rb +5 -0
  14. data/lib/stripe_model_callbacks/factories/stripe_plans.rb +28 -0
  15. data/lib/stripe_model_callbacks/factories/stripe_products.rb +5 -0
  16. data/lib/stripe_model_callbacks/factories/stripe_recipients.rb +5 -0
  17. data/lib/stripe_model_callbacks/factories/stripe_refunds.rb +9 -0
  18. data/lib/stripe_model_callbacks/factories/stripe_reviews.rb +6 -0
  19. data/lib/stripe_model_callbacks/factories/stripe_skus.rb +7 -0
  20. data/lib/stripe_model_callbacks/factories/stripe_sources.rb +8 -0
  21. data/lib/stripe_model_callbacks/factories/stripe_subscription_items.rb +19 -0
  22. data/lib/stripe_model_callbacks/factories/stripe_subscriptions.rb +40 -0
  23. data/lib/stripe_model_callbacks/factories/stripe_transfers.rb +8 -0
  24. data/lib/stripe_model_callbacks/factory_bot_definitions.rb +1 -1
  25. data/lib/stripe_model_callbacks/version.rb +1 -1
  26. metadata +27 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9d3e6bf9290c17976c275cdabe05a67ba264a3ddb8f1f7af6b75dc4daea6b29
4
- data.tar.gz: 0bd3eea3af9cf54996441dfd0e33969ce114107a42f01aee61b93185a16bee33
3
+ metadata.gz: e8960c2c38ee84c3e3bca2584f510517c5b2e376b644ded3f32e78e9cb8a854e
4
+ data.tar.gz: caaffd9c4bf3d43a93b6a1f0c1fc849816da7533febd828db507809c8882efcb
5
5
  SHA512:
6
- metadata.gz: e280ae9def15e1de122489e8a348949dc9e86af188650fef9d18bcf217be5bf52ef04df9c5e73b563e27a6208dc681f313ced34c7e0da4c5b680bfaa125c9c74
7
- data.tar.gz: 1d99e5f48fd7c022d06406bb5b1b52b55ce21822b8d1190f702f0465f1f8317ec0aa202df46e2af59d3cd4b967f12ad32d9e4acec3c8595a040e951b6216ec48
6
+ metadata.gz: 77eb0b8e66fbeebb8b0dd1034cbd87423ab3632ac7be297704ad22ebc9fda8cdb460a53896d97e183d7c04ec48d440feb6c0b72af41e52d22c3e317295a0e3d9
7
+ data.tar.gz: 45718f0c45e6b896ee8d2e3127084adb652edb1587d0666deaf8c6c9d7829c1d7bd51498d89b7b0135af7a8c2d45338b736a90bd4e37c347e4c14ccd12d6cf2a
@@ -0,0 +1,5 @@
1
+ FactoryBot.define do
2
+ factory :stripe_bank_account do
3
+ sequence(:stripe_id) { |n| "stripe-bank-account-#{n}" }
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ FactoryBot.define do
2
+ factory :stripe_card do
3
+ sequence(:stripe_id) { |n| "stripe-card-#{n}" }
4
+ last4 { "4242" }
5
+ stripe_customer
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ FactoryBot.define do
2
+ factory :stripe_charge do
3
+ sequence(:stripe_id) { |n| "stripe-charge-#{n}" }
4
+ amount { Money.new(100, "USD") }
5
+ captured { false }
6
+ currency { "usd" }
7
+ livemode { false }
8
+ paid { false }
9
+ refunded { false }
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ FactoryBot.define do
2
+ factory :stripe_coupon do
3
+ sequence(:stripe_id) { |n| "stripe-coupon-#{n}" }
4
+ end
5
+ end
@@ -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,6 @@
1
+ FactoryBot.define do
2
+ factory :stripe_discount do
3
+ stripe_coupon
4
+ stripe_customer
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ FactoryBot.define do
2
+ factory :stripe_dispute do
3
+ sequence(:stripe_id) { |n| "stripe-dispute-#{n}" }
4
+ amount { Money.new(1000, "USD") }
5
+ currency { "usd" }
6
+ end
7
+ 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,8 @@
1
+ FactoryBot.define do
2
+ factory :stripe_order_item do
3
+ sequence(:parent_id) { |n| "stripe-order-line-#{n}" }
4
+ stripe_order
5
+ amount { Money.new(1000, "USD") }
6
+ currency { "usd" }
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ FactoryBot.define do
2
+ factory :stripe_order do
3
+ sequence(:stripe_id) { |n| "stripe-order-#{n}" }
4
+ amount { Money.new(1000, "USD") }
5
+ currency { "usd" }
6
+ livemode { false }
7
+ status { "created" }
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ FactoryBot.define do
2
+ factory :stripe_payout do
3
+ sequence(:stripe_id) { |n| "stripe-payout-#{n}" }
4
+ end
5
+ 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,5 @@
1
+ FactoryBot.define do
2
+ factory :stripe_product do
3
+ sequence(:stripe_id) { |n| "stripe-product-#{n}" }
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ FactoryBot.define do
2
+ factory :stripe_recipient do
3
+ sequence(:stripe_id) { |n| "stripe-recipient-#{n}" }
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ FactoryBot.define do
2
+ factory :stripe_refund do
3
+ sequence(:stripe_id) { |n| "stripe-refund-#{n}" }
4
+ stripe_charge
5
+ currency { "usd" }
6
+ amount { Money.new(1000, "USD") }
7
+ livemode { false }
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :stripe_review do
3
+ sequence(:stripe_id) { |n| "stripe-review-#{n}" }
4
+ stripe_charge
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ FactoryBot.define do
2
+ factory :stripe_sku do
3
+ sequence(:stripe_id) { |n| "stripe-sku-#{n}" }
4
+ price { Money.new(10_000, "USD") }
5
+ currency { "usd" }
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :stripe_source do
3
+ sequence(:stripe_id) { |n| "stripe-source-#{n}" }
4
+ client_secret { "CLIENT-FAKE-SECRET" }
5
+ flow { "receiver" }
6
+ livemode { false }
7
+ end
8
+ 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
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :stripe_transfer do
3
+ sequence(:stripe_id) { |n| "stripe-transfer-#{n}" }
4
+ amount { Money.new(10_000, "USD") }
5
+ amount_reversed { Money.new(0, "USD") }
6
+ currency { "usd" }
7
+ end
8
+ end
@@ -1,4 +1,4 @@
1
- factories_path = File.realpath("#{File.dirname(__FILE__)}/../../spec/factories")
1
+ factories_path = File.realpath("#{File.dirname(__FILE__)}/factories")
2
2
 
3
3
  Dir.foreach(factories_path) do |file|
4
4
  next unless /\A(.+)\.rb\Z/.match?(file)
@@ -1,3 +1,3 @@
1
1
  module StripeModelCallbacks
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  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.0
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: '0'
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: '0'
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