solidus_subscriptions 1.0.0.rc1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +57 -9
  3. data/.github/dependabot.yml +7 -0
  4. data/.rubocop.yml +3 -0
  5. data/CHANGELOG.md +201 -163
  6. data/Gemfile +14 -1
  7. data/README.md +17 -7
  8. data/app/controllers/solidus_subscriptions/api/v1/subscriptions_controller.rb +25 -1
  9. data/app/controllers/spree/admin/subscriptions_controller.rb +32 -4
  10. data/app/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions.rb +2 -2
  11. data/app/decorators/models/solidus_subscriptions/spree/wallet_payment_source/report_default_change_to_subscriptions.rb +2 -2
  12. data/app/jobs/solidus_subscriptions/create_subscription_job.rb +11 -0
  13. data/app/jobs/solidus_subscriptions/process_installment_job.rb +1 -1
  14. data/app/models/solidus_subscriptions/subscription.rb +75 -31
  15. data/app/subscribers/solidus_subscriptions/churn_buster_subscriber.rb +1 -0
  16. data/app/subscribers/solidus_subscriptions/event_storage_subscriber.rb +1 -0
  17. data/app/subscribers/solidus_subscriptions/order_subscriber.rb +16 -0
  18. data/app/views/spree/admin/shared/_subscription_actions.html.erb +27 -8
  19. data/app/views/spree/admin/shared/_subscription_sidebar.html.erb +2 -0
  20. data/app/views/spree/admin/subscriptions/_state_pill.html.erb +3 -2
  21. data/app/views/spree/admin/subscriptions/index.html.erb +50 -13
  22. data/bin/sandbox +1 -6
  23. data/config/locales/en.yml +16 -0
  24. data/config/routes.rb +9 -3
  25. data/db/migrate/20210905145955_add_paused_to_subscriptions.rb +5 -0
  26. data/{app/decorators → lib/decorators/api}/controllers/solidus_subscriptions/spree/api/line_items_controller/create_subscription_line_items.rb +14 -0
  27. data/lib/generators/solidus_subscriptions/install/install_generator.rb +16 -0
  28. data/lib/generators/solidus_subscriptions/install/templates/app/controllers/concerns/create_subscription.rb +17 -0
  29. data/lib/generators/solidus_subscriptions/install/templates/app/views/cart_line_items/_subscription_fields.html.erb +30 -0
  30. data/lib/generators/solidus_subscriptions/install/templates/initializer.rb +16 -1
  31. data/lib/solidus_subscriptions/checkout.rb +2 -9
  32. data/lib/solidus_subscriptions/configuration.rb +37 -8
  33. data/lib/solidus_subscriptions/dispatcher/payment_failed_dispatcher.rb +2 -2
  34. data/lib/solidus_subscriptions/dispatcher/success_dispatcher.rb +2 -2
  35. data/lib/solidus_subscriptions/engine.rb +28 -0
  36. data/lib/solidus_subscriptions/order_creator.rb +29 -0
  37. data/lib/solidus_subscriptions/permission_sets/default_customer.rb +1 -1
  38. data/lib/solidus_subscriptions/processing_error_handlers/rails_logger.rb +25 -0
  39. data/lib/solidus_subscriptions/subscription_generator.rb +6 -0
  40. data/lib/solidus_subscriptions/version.rb +1 -1
  41. data/lib/solidus_subscriptions.rb +1 -0
  42. data/solidus_subscriptions.gemspec +6 -6
  43. data/spec/controllers/spree/api/line_items_controller_spec.rb +63 -28
  44. data/spec/controllers/spree/api/users_controller_spec.rb +3 -0
  45. data/spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb +4 -4
  46. data/spec/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions_spec.rb +2 -2
  47. data/spec/features/admin/subscriptions_spec.rb +13 -3
  48. data/spec/jobs/solidus_subscriptions/create_subscription_job_spec.rb +20 -0
  49. data/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb +17 -0
  50. data/spec/lib/solidus_subscriptions/dispatcher/payment_failed_dispatcher_spec.rb +3 -3
  51. data/spec/lib/solidus_subscriptions/dispatcher/success_dispatcher_spec.rb +3 -3
  52. data/spec/lib/solidus_subscriptions/subscription_generator_spec.rb +1 -1
  53. data/spec/models/solidus_subscriptions/installment_spec.rb +1 -1
  54. data/spec/models/solidus_subscriptions/subscription_spec.rb +893 -16
  55. data/spec/models/spree/wallet_payment_source_spec.rb +3 -3
  56. data/spec/requests/api/v1/subscriptions_spec.rb +229 -0
  57. data/spec/subscribers/solidus_subscriptions/churn_buster_subscriber_spec.rb +8 -8
  58. data/spec/subscribers/solidus_subscriptions/order_subscriber_spec.rb +13 -0
  59. metadata +31 -23
  60. data/app/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions.rb +0 -23
  61. data/config/initializers/subscribers.rb +0 -9
  62. data/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb +0 -32
  63. /data/{app/decorators → lib/decorators/frontend}/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items.rb +0 -0
  64. /data/{app → lib}/views/spree/frontend/products/_subscription_line_item_fields.html.erb +0 -0
@@ -3,7 +3,7 @@
3
3
  RSpec.describe Spree::WalletPaymentSource do
4
4
  describe 'setting it as the default' do
5
5
  it 'reports a payment method changed event for subscriptions that use the default payment source' do
6
- stub_const('Spree::Event', class_spy(Spree::Event))
6
+ stub_const('SolidusSupport::LegacyEventCompat::Bus', class_spy(SolidusSupport::LegacyEventCompat::Bus))
7
7
  user = create(:user)
8
8
  subscription = create(:subscription, user: user)
9
9
  payment_source = create(:credit_card, user: user)
@@ -11,8 +11,8 @@ RSpec.describe Spree::WalletPaymentSource do
11
11
 
12
12
  user.wallet.default_wallet_payment_source = wallet_payment_source
13
13
 
14
- expect(Spree::Event).to have_received(:fire).with(
15
- 'solidus_subscriptions.subscription_payment_method_changed',
14
+ expect(SolidusSupport::LegacyEventCompat::Bus).to have_received(:publish).with(
15
+ :'solidus_subscriptions.subscription_payment_method_changed',
16
16
  subscription: subscription,
17
17
  )
18
18
  end
@@ -163,6 +163,235 @@ RSpec.describe '/api/v1/subscriptions' do
163
163
  end
164
164
  end
165
165
 
166
+ describe 'POST /:id/pause' do
167
+ context 'when the subscription is active and belongs to the user' do
168
+ context 'with an actionable_date' do
169
+ it 'pauses the subscription and updates the actionable_date' do
170
+ user = create(:user, &:generate_spree_api_key!)
171
+ subscription = create(
172
+ :subscription,
173
+ user: user,
174
+ paused: false,
175
+ state: 'active'
176
+ )
177
+ date = Time.zone.tomorrow + 1.day
178
+ params = {
179
+ subscription: {
180
+ actionable_date: date
181
+ }
182
+ }
183
+
184
+ post(
185
+ pause_api_v1_subscription_path(subscription),
186
+ headers: { 'Authorization' => "Bearer #{user.spree_api_key}" },
187
+ params: params
188
+ )
189
+
190
+ aggregate_failures do
191
+ expect(response).to be_ok
192
+ expect(subscription.reload.actionable_date).to eq(date)
193
+ expect(subscription.paused).to eq(true)
194
+ end
195
+ end
196
+ end
197
+
198
+ context 'without an actionable_date' do
199
+ it 'pauses the subscription indefinitely' do
200
+ user = create(:user, &:generate_spree_api_key!)
201
+ subscription = create(
202
+ :subscription,
203
+ :with_shipping_address,
204
+ user: user,
205
+ paused: false,
206
+ state: 'active'
207
+ )
208
+ params = nil
209
+
210
+ post(
211
+ pause_api_v1_subscription_path(subscription),
212
+ headers: { 'Authorization' => "Bearer #{user.spree_api_key}" },
213
+ params: params
214
+ )
215
+
216
+ aggregate_failures do
217
+ expect(response).to be_ok
218
+ expect(subscription.reload.actionable_date).to be_nil
219
+ expect(subscription.paused).to eq(true)
220
+ end
221
+ end
222
+ end
223
+ end
224
+
225
+ context 'when the subscription is not active and belongs to the user' do
226
+ it 'is an unprocessable entity' do
227
+ user = create(:user, &:generate_spree_api_key!)
228
+ subscription = create(
229
+ :subscription,
230
+ :with_shipping_address,
231
+ user: user,
232
+ paused: false,
233
+ state: 'canceled'
234
+ )
235
+ params = nil
236
+
237
+ post(
238
+ pause_api_v1_subscription_path(subscription),
239
+ headers: { 'Authorization' => "Bearer #{user.spree_api_key}" },
240
+ params: params
241
+ )
242
+
243
+ aggregate_failures do
244
+ expect(response).to have_http_status(:unprocessable_entity)
245
+ expect(JSON.parse(response.body)["paused"]).to include('cannot pause/resume a subscription which is not active')
246
+ expect(subscription.reload.paused).to eq(false)
247
+ end
248
+ end
249
+ end
250
+
251
+ context('when the subscription is active but does not belong to the user') do
252
+ it 'responds with 401 Unauthorized' do
253
+ user = create(:user, &:generate_spree_api_key!)
254
+ subscription = create(
255
+ :subscription,
256
+ paused: false,
257
+ state: 'active'
258
+ )
259
+ date = Time.zone.tomorrow + 1.day
260
+ params = {
261
+ subscription: {
262
+ actionable_date: date
263
+ }
264
+ }
265
+
266
+ post(
267
+ pause_api_v1_subscription_path(subscription),
268
+ headers: { 'Authorization' => "Bearer #{user.spree_api_key}" },
269
+ params: params
270
+ )
271
+
272
+ expect(response.status).to eq(401)
273
+ end
274
+ end
275
+ end
276
+
277
+ describe '#resume' do
278
+ context 'when the subscription is active and belongs to the user' do
279
+ context 'with an actionable_date' do
280
+ it 'resumes the subscription and updates the actionable_date' do
281
+ user = create(:user, &:generate_spree_api_key!)
282
+ subscription = create(
283
+ :subscription,
284
+ user: user,
285
+ paused: true,
286
+ state: 'active'
287
+ )
288
+ date = Time.zone.tomorrow + 1.day
289
+ params = {
290
+ subscription: {
291
+ actionable_date: date
292
+ }
293
+ }
294
+
295
+ post(
296
+ resume_api_v1_subscription_path(subscription),
297
+ headers: { 'Authorization' => "Bearer #{user.spree_api_key}" },
298
+ params: params
299
+ )
300
+
301
+ aggregate_failures do
302
+ expect(response).to be_ok
303
+ expect(subscription.reload.actionable_date).to eq(date)
304
+ expect(subscription.paused).to eq(false)
305
+ end
306
+ end
307
+ end
308
+
309
+ context 'without an actionable_date' do
310
+ it 'resumes the subscription on the next day' do
311
+ user = create(:user, &:generate_spree_api_key!)
312
+ subscription = create(
313
+ :subscription,
314
+ user: user,
315
+ paused: true,
316
+ state: 'active'
317
+ )
318
+ params = {
319
+ subscription: {
320
+ actionable_date: nil
321
+ }
322
+ }
323
+
324
+ post(
325
+ resume_api_v1_subscription_path(subscription),
326
+ headers: { 'Authorization' => "Bearer #{user.spree_api_key}" },
327
+ params: params
328
+ )
329
+
330
+ aggregate_failures do
331
+ expect(response).to be_ok
332
+ expect(subscription.reload.actionable_date).to eq(Time.zone.tomorrow)
333
+ expect(subscription.paused).to eq(false)
334
+ end
335
+ end
336
+ end
337
+ end
338
+
339
+ context 'when the subscription is not active and belongs to the user' do
340
+ it 'is an unprocessable entity' do
341
+ user = create(:user, &:generate_spree_api_key!)
342
+ subscription = create(
343
+ :subscription,
344
+ user: user,
345
+ paused: true,
346
+ state: 'canceled'
347
+ )
348
+ params = {
349
+ subscription: {
350
+ actionable_date: nil
351
+ }
352
+ }
353
+
354
+ post(
355
+ resume_api_v1_subscription_path(subscription),
356
+ headers: { 'Authorization' => "Bearer #{user.spree_api_key}" },
357
+ params: params
358
+ )
359
+
360
+ aggregate_failures do
361
+ expect(response.status).to eq(422)
362
+ expect(JSON.parse(response.body)["paused"]).to include('cannot pause/resume a subscription which is not active')
363
+ end
364
+ end
365
+ end
366
+
367
+ context 'when the subscription is active but does not belong to the user' do
368
+ it 'responds with 401 Unauthorized' do
369
+ user = create(:user, &:generate_spree_api_key!)
370
+ subscription = create(
371
+ :subscription,
372
+ paused: true,
373
+ state: 'active'
374
+ )
375
+ params = {
376
+ subscription: {
377
+ actionable_date: nil
378
+ }
379
+ }
380
+
381
+ post(
382
+ resume_api_v1_subscription_path(subscription),
383
+ headers: { 'Authorization' => "Bearer #{user.spree_api_key}" },
384
+ params: params
385
+ )
386
+
387
+ aggregate_failures do
388
+ expect(response.status).to eq(401)
389
+ expect(subscription.paused).to eq(true)
390
+ end
391
+ end
392
+ end
393
+ end
394
+
166
395
  describe 'POST /:id/skip' do
167
396
  context 'when the subscription belongs to the user' do
168
397
  it 'responds with 200 OK' do
@@ -7,7 +7,7 @@ RSpec.describe SolidusSubscriptions::ChurnBusterSubscriber do
7
7
  allow(SolidusSubscriptions).to receive(:churn_buster).and_return(churn_buster)
8
8
 
9
9
  subscription = create(:subscription)
10
- Spree::Event.fire('solidus_subscriptions.subscription_canceled', subscription: subscription)
10
+ SolidusSupport::LegacyEventCompat::Bus.publish(:'solidus_subscriptions.subscription_canceled', subscription: subscription)
11
11
 
12
12
  expect(churn_buster).to have_received(:report_subscription_cancellation).with(subscription)
13
13
  end
@@ -19,7 +19,7 @@ RSpec.describe SolidusSubscriptions::ChurnBusterSubscriber do
19
19
  allow(SolidusSubscriptions).to receive(:churn_buster).and_return(churn_buster)
20
20
 
21
21
  subscription = create(:subscription)
22
- Spree::Event.fire('solidus_subscriptions.subscription_ended', subscription: subscription)
22
+ SolidusSupport::LegacyEventCompat::Bus.publish(:'solidus_subscriptions.subscription_ended', subscription: subscription)
23
23
 
24
24
  expect(churn_buster).to have_received(:report_subscription_cancellation).with(subscription)
25
25
  end
@@ -32,8 +32,8 @@ RSpec.describe SolidusSubscriptions::ChurnBusterSubscriber do
32
32
 
33
33
  order = build_stubbed(:order)
34
34
  installment = build_stubbed(:installment)
35
- Spree::Event.fire(
36
- 'solidus_subscriptions.installment_succeeded',
35
+ SolidusSupport::LegacyEventCompat::Bus.publish(
36
+ :'solidus_subscriptions.installment_succeeded',
37
37
  installment: installment,
38
38
  order: order,
39
39
  )
@@ -49,8 +49,8 @@ RSpec.describe SolidusSubscriptions::ChurnBusterSubscriber do
49
49
 
50
50
  order = build_stubbed(:order)
51
51
  installment = build_stubbed(:installment)
52
- Spree::Event.fire(
53
- 'solidus_subscriptions.installment_failed_payment',
52
+ SolidusSupport::LegacyEventCompat::Bus.publish(
53
+ :'solidus_subscriptions.installment_failed_payment',
54
54
  installment: installment,
55
55
  order: order,
56
56
  )
@@ -65,8 +65,8 @@ RSpec.describe SolidusSubscriptions::ChurnBusterSubscriber do
65
65
  allow(SolidusSubscriptions).to receive(:churn_buster).and_return(churn_buster)
66
66
 
67
67
  subscription = create(:subscription)
68
- Spree::Event.fire(
69
- 'solidus_subscriptions.subscription_payment_method_changed',
68
+ SolidusSupport::LegacyEventCompat::Bus.publish(
69
+ :'solidus_subscriptions.subscription_payment_method_changed',
70
70
  subscription: subscription,
71
71
  )
72
72
 
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe SolidusSubscriptions::OrderSubscriber do
4
+ describe 'on order completion' do
5
+ it 'enqueues the CreateSubscriptionJob' do
6
+ order = create(:order_ready_to_complete, :with_subscription_line_items)
7
+
8
+ order.complete!
9
+
10
+ expect(SolidusSubscriptions::CreateSubscriptionJob).to have_been_enqueued.with(order).once
11
+ end
12
+ end
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_subscriptions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-02 00:00:00.000000000 Z
11
+ date: 2023-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -58,34 +58,34 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 2.0.0
61
+ version: '2.11'
62
62
  - - "<"
63
63
  - !ruby/object:Gem::Version
64
- version: '3'
64
+ version: '4'
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: 2.0.0
71
+ version: '2.11'
72
72
  - - "<"
73
73
  - !ruby/object:Gem::Version
74
- version: '3'
74
+ version: '4'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: solidus_support
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '0.7'
81
+ version: '0.9'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '0.7'
88
+ version: '0.9'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: state_machines
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -220,6 +220,7 @@ extra_rdoc_files: []
220
220
  files:
221
221
  - ".circleci/config.yml"
222
222
  - ".gem_release.yml"
223
+ - ".github/dependabot.yml"
223
224
  - ".github/stale.yml"
224
225
  - ".github_changelog_generator"
225
226
  - ".gitignore"
@@ -241,11 +242,8 @@ files:
241
242
  - app/controllers/spree/admin/subscription_orders_controller.rb
242
243
  - app/controllers/spree/admin/subscriptions_controller.rb
243
244
  - app/controllers/spree/admin/users/subscriptions_controller.rb
244
- - app/decorators/controllers/solidus_subscriptions/spree/api/line_items_controller/create_subscription_line_items.rb
245
- - app/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items.rb
246
245
  - app/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association.rb
247
246
  - app/decorators/models/solidus_subscriptions/spree/order/after_create.rb
248
- - app/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions.rb
249
247
  - app/decorators/models/solidus_subscriptions/spree/order/installment_details_association.rb
250
248
  - app/decorators/models/solidus_subscriptions/spree/order/subscription_association.rb
251
249
  - app/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association.rb
@@ -254,6 +252,7 @@ files:
254
252
  - app/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions.rb
255
253
  - app/decorators/models/solidus_subscriptions/spree/variant/variant_pretty_name.rb
256
254
  - app/decorators/models/solidus_subscriptions/spree/wallet_payment_source/report_default_change_to_subscriptions.rb
255
+ - app/jobs/solidus_subscriptions/create_subscription_job.rb
257
256
  - app/jobs/solidus_subscriptions/process_installment_job.rb
258
257
  - app/jobs/solidus_subscriptions/process_subscription_job.rb
259
258
  - app/models/solidus_subscriptions/installment.rb
@@ -271,6 +270,7 @@ files:
271
270
  - app/overrides/views/subscription_line_item_fields.rb
272
271
  - app/subscribers/solidus_subscriptions/churn_buster_subscriber.rb
273
272
  - app/subscribers/solidus_subscriptions/event_storage_subscriber.rb
273
+ - app/subscribers/solidus_subscriptions/order_subscriber.rb
274
274
  - app/views/spree/admin/installments/_state_pill.html.erb
275
275
  - app/views/spree/admin/installments/index.html.erb
276
276
  - app/views/spree/admin/products/_subscribable_checkbox.html.erb
@@ -293,7 +293,6 @@ files:
293
293
  - app/views/spree/admin/users/_subscription_tab.html.erb
294
294
  - app/views/spree/admin/users/subscriptions/index.html.erb
295
295
  - app/views/spree/admin/variants/_subscribable_checkbox.html.erb
296
- - app/views/spree/frontend/products/_subscription_line_item_fields.html.erb
297
296
  - bin/console
298
297
  - bin/rails
299
298
  - bin/rails-engine
@@ -302,7 +301,6 @@ files:
302
301
  - bin/sandbox
303
302
  - bin/setup
304
303
  - config/initializers/permission_sets.rb
305
- - config/initializers/subscribers.rb
306
304
  - config/locales/en.yml
307
305
  - config/routes.rb
308
306
  - db/migrate/20160825164850_create_solidus_subscriptions_subscriptions.rb
@@ -336,7 +334,12 @@ files:
336
334
  - db/migrate/20201123171026_change_actionable_date_to_date.rb
337
335
  - db/migrate/20210205140422_add_currency_to_subscription.rb
338
336
  - db/migrate/20210323165714_update_promotion_rule_names.rb
337
+ - db/migrate/20210905145955_add_paused_to_subscriptions.rb
338
+ - lib/decorators/api/controllers/solidus_subscriptions/spree/api/line_items_controller/create_subscription_line_items.rb
339
+ - lib/decorators/frontend/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items.rb
339
340
  - lib/generators/solidus_subscriptions/install/install_generator.rb
341
+ - lib/generators/solidus_subscriptions/install/templates/app/controllers/concerns/create_subscription.rb
342
+ - lib/generators/solidus_subscriptions/install/templates/app/views/cart_line_items/_subscription_fields.html.erb
340
343
  - lib/generators/solidus_subscriptions/install/templates/initializer.rb
341
344
  - lib/solidus_subscriptions.rb
342
345
  - lib/solidus_subscriptions/checkout.rb
@@ -353,9 +356,11 @@ files:
353
356
  - lib/solidus_subscriptions/dispatcher/payment_failed_dispatcher.rb
354
357
  - lib/solidus_subscriptions/dispatcher/success_dispatcher.rb
355
358
  - lib/solidus_subscriptions/engine.rb
359
+ - lib/solidus_subscriptions/order_creator.rb
356
360
  - lib/solidus_subscriptions/permission_sets/default_customer.rb
357
361
  - lib/solidus_subscriptions/permission_sets/subscription_management.rb
358
362
  - lib/solidus_subscriptions/permitted_attributes.rb
363
+ - lib/solidus_subscriptions/processing_error_handlers/rails_logger.rb
359
364
  - lib/solidus_subscriptions/processor.rb
360
365
  - lib/solidus_subscriptions/subscription_generator.rb
361
366
  - lib/solidus_subscriptions/subscription_line_item_builder.rb
@@ -369,6 +374,7 @@ files:
369
374
  - lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
370
375
  - lib/solidus_subscriptions/version.rb
371
376
  - lib/tasks/process_subscriptions.rake
377
+ - lib/views/spree/frontend/products/_subscription_line_item_fields.html.erb
372
378
  - reference/solidus_subscriptions.v1.yaml
373
379
  - solidus_subscriptions.gemspec
374
380
  - spec/controllers/spree/admin/subscriptions_controller_spec.rb
@@ -377,7 +383,6 @@ files:
377
383
  - spec/controllers/spree/api/users_controller_spec.rb
378
384
  - spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb
379
385
  - spec/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association_spec.rb
380
- - spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb
381
386
  - spec/decorators/models/solidus_subscriptions/spree/order/installment_details_association_spec.rb
382
387
  - spec/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association_spec.rb
383
388
  - spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb
@@ -386,6 +391,7 @@ files:
386
391
  - spec/features/admin/subscriptions_spec.rb
387
392
  - spec/features/admin_users_subscription_tabs_spec.rb
388
393
  - spec/fixtures/cassettes/churn_buster.yml
394
+ - spec/jobs/solidus_subscriptions/create_subscription_job_spec.rb
389
395
  - spec/jobs/solidus_subscriptions/process_installment_job_spec.rb
390
396
  - spec/jobs/solidus_subscriptions/process_subscription_job_spec.rb
391
397
  - spec/lib/solidus_subscriptions/checkout_spec.rb
@@ -411,6 +417,7 @@ files:
411
417
  - spec/requests/api/v1/subscriptions_spec.rb
412
418
  - spec/spec_helper.rb
413
419
  - spec/subscribers/solidus_subscriptions/churn_buster_subscriber_spec.rb
420
+ - spec/subscribers/solidus_subscriptions/order_subscriber_spec.rb
414
421
  - spec/support/active_model_mocks.rb
415
422
  - spec/support/cancancan.rb
416
423
  - spec/support/factories.rb
@@ -420,29 +427,29 @@ files:
420
427
  - spec/support/timecop.rb
421
428
  - spec/support/vcr.rb
422
429
  - spec/support/version_cake.rb
423
- homepage: https://github.com/solidusio-contrib/solidus_subscriptions
430
+ homepage: https://github.com/solidusio/solidus_subscriptions
424
431
  licenses:
425
432
  - BSD-3-Clause
426
433
  metadata:
427
- homepage_uri: https://github.com/solidusio-contrib/solidus_subscriptions
428
- source_code_uri: https://github.com/solidusio-contrib/solidus_subscriptions
429
- changelog_uri: https://github.com/solidusio-contrib/solidus_subscriptions/blob/master/CHANGELOG.md
434
+ homepage_uri: https://github.com/solidusio/solidus_subscriptions
435
+ source_code_uri: https://github.com/solidusio/solidus_subscriptions
436
+ changelog_uri: https://github.com/solidusio/solidus_subscriptions/blob/master/CHANGELOG.md
430
437
  post_install_message:
431
438
  rdoc_options: []
432
439
  require_paths:
433
440
  - lib
434
441
  required_ruby_version: !ruby/object:Gem::Requirement
435
442
  requirements:
436
- - - "~>"
443
+ - - ">="
437
444
  - !ruby/object:Gem::Version
438
445
  version: '2.5'
439
446
  required_rubygems_version: !ruby/object:Gem::Requirement
440
447
  requirements:
441
- - - ">"
448
+ - - ">="
442
449
  - !ruby/object:Gem::Version
443
- version: 1.3.1
450
+ version: '0'
444
451
  requirements: []
445
- rubygems_version: 3.0.3
452
+ rubygems_version: 3.3.7
446
453
  signing_key:
447
454
  specification_version: 4
448
455
  summary: Add subscription support to Solidus
@@ -453,7 +460,6 @@ test_files:
453
460
  - spec/controllers/spree/api/users_controller_spec.rb
454
461
  - spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb
455
462
  - spec/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association_spec.rb
456
- - spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb
457
463
  - spec/decorators/models/solidus_subscriptions/spree/order/installment_details_association_spec.rb
458
464
  - spec/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association_spec.rb
459
465
  - spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb
@@ -462,6 +468,7 @@ test_files:
462
468
  - spec/features/admin/subscriptions_spec.rb
463
469
  - spec/features/admin_users_subscription_tabs_spec.rb
464
470
  - spec/fixtures/cassettes/churn_buster.yml
471
+ - spec/jobs/solidus_subscriptions/create_subscription_job_spec.rb
465
472
  - spec/jobs/solidus_subscriptions/process_installment_job_spec.rb
466
473
  - spec/jobs/solidus_subscriptions/process_subscription_job_spec.rb
467
474
  - spec/lib/solidus_subscriptions/checkout_spec.rb
@@ -487,6 +494,7 @@ test_files:
487
494
  - spec/requests/api/v1/subscriptions_spec.rb
488
495
  - spec/spec_helper.rb
489
496
  - spec/subscribers/solidus_subscriptions/churn_buster_subscriber_spec.rb
497
+ - spec/subscribers/solidus_subscriptions/order_subscriber_spec.rb
490
498
  - spec/support/active_model_mocks.rb
491
499
  - spec/support/cancancan.rb
492
500
  - spec/support/factories.rb
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Once an order is finalized its subscriptions line items should be converted
4
- # into active subscriptions. This hooks into Spree::Order#finalize! and
5
- # passes all subscription_line_items present on the order to the Subscription
6
- # generator which will build and persist the subscriptions
7
- module SolidusSubscriptions
8
- module Spree
9
- module Order
10
- module FinalizeCreatesSubscriptions
11
- def finalize!
12
- SolidusSubscriptions::SubscriptionGenerator.group(subscription_line_items).each do |line_items|
13
- SolidusSubscriptions::SubscriptionGenerator.activate(line_items)
14
- end
15
-
16
- super
17
- end
18
- end
19
- end
20
- end
21
- end
22
-
23
- Spree::Order.prepend(SolidusSubscriptions::Spree::Order::FinalizeCreatesSubscriptions)
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if Spree.solidus_gem_version < Gem::Version.new('2.11.0')
4
- require SolidusSubscriptions::Engine.root.join('app/subscribers/solidus_subscriptions/event_storage_subscriber')
5
- require SolidusSubscriptions::Engine.root.join('app/subscribers/solidus_subscriptions/churn_buster_subscriber')
6
-
7
- SolidusSubscriptions::ChurnBusterSubscriber.subscribe!
8
- SolidusSubscriptions::EventStorageSubscriber.subscribe!
9
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe SolidusSubscriptions::Spree::Order::FinalizeCreatesSubscriptions do
6
- describe '#finalize!' do
7
- subject(:finalize) { order.finalize! }
8
-
9
- let(:order) { create :order, :with_subscription_line_items }
10
- let(:subscription_line_item) { order.subscription_line_items.last }
11
- let(:expected_actionable_date) { Time.zone.today + subscription_line_item.interval }
12
-
13
- around { |e| Timecop.freeze { e.run } }
14
-
15
- it 'creates new subscriptions' do
16
- expect { finalize }.
17
- to change { SolidusSubscriptions::Subscription.count }.
18
- by(order.subscription_line_items.count)
19
- end
20
-
21
- it 'creates a subscription with the correct values' do
22
- finalize
23
- subscription = SolidusSubscriptions::Subscription.last
24
-
25
- expect(subscription).to have_attributes(
26
- user_id: order.user_id,
27
- actionable_date: expected_actionable_date,
28
- line_items: [subscription_line_item]
29
- )
30
- end
31
- end
32
- end