solidus_subscriptions 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +57 -9
- data/.github/dependabot.yml +7 -0
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +201 -169
- data/Gemfile +14 -1
- data/README.md +17 -7
- data/app/controllers/solidus_subscriptions/api/v1/subscriptions_controller.rb +24 -0
- data/app/controllers/spree/admin/subscriptions_controller.rb +32 -4
- data/app/decorators/models/solidus_subscriptions/spree/wallet_payment_source/report_default_change_to_subscriptions.rb +2 -2
- data/app/jobs/solidus_subscriptions/create_subscription_job.rb +11 -0
- data/app/jobs/solidus_subscriptions/process_installment_job.rb +1 -1
- data/app/models/solidus_subscriptions/subscription.rb +75 -31
- data/app/subscribers/solidus_subscriptions/churn_buster_subscriber.rb +1 -0
- data/app/subscribers/solidus_subscriptions/event_storage_subscriber.rb +1 -0
- data/app/subscribers/solidus_subscriptions/order_subscriber.rb +16 -0
- data/app/views/spree/admin/shared/_subscription_actions.html.erb +27 -8
- data/app/views/spree/admin/shared/_subscription_sidebar.html.erb +2 -0
- data/app/views/spree/admin/subscriptions/_state_pill.html.erb +3 -2
- data/app/views/spree/admin/subscriptions/index.html.erb +50 -13
- data/bin/sandbox +1 -6
- data/config/locales/en.yml +16 -0
- data/config/routes.rb +9 -3
- data/db/migrate/20210905145955_add_paused_to_subscriptions.rb +5 -0
- data/lib/decorators/api/controllers/solidus_subscriptions/spree/api/line_items_controller/create_subscription_line_items.rb +14 -0
- data/lib/generators/solidus_subscriptions/install/install_generator.rb +16 -0
- data/lib/generators/solidus_subscriptions/install/templates/app/controllers/concerns/create_subscription.rb +17 -0
- data/lib/generators/solidus_subscriptions/install/templates/app/views/cart_line_items/_subscription_fields.html.erb +30 -0
- data/lib/generators/solidus_subscriptions/install/templates/initializer.rb +3 -1
- data/lib/solidus_subscriptions/configuration.rb +29 -6
- data/lib/solidus_subscriptions/dispatcher/payment_failed_dispatcher.rb +2 -2
- data/lib/solidus_subscriptions/dispatcher/success_dispatcher.rb +2 -2
- data/lib/solidus_subscriptions/engine.rb +28 -0
- data/lib/solidus_subscriptions/permission_sets/default_customer.rb +1 -1
- data/lib/solidus_subscriptions/processing_error_handlers/rails_logger.rb +25 -0
- data/lib/solidus_subscriptions/subscription_generator.rb +6 -0
- data/lib/solidus_subscriptions/version.rb +1 -1
- data/solidus_subscriptions.gemspec +6 -6
- data/spec/controllers/spree/api/line_items_controller_spec.rb +63 -28
- data/spec/controllers/spree/api/users_controller_spec.rb +3 -0
- data/spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb +4 -4
- data/spec/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions_spec.rb +2 -2
- data/spec/features/admin/subscriptions_spec.rb +13 -3
- data/spec/jobs/solidus_subscriptions/create_subscription_job_spec.rb +20 -0
- data/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb +17 -0
- data/spec/lib/solidus_subscriptions/dispatcher/payment_failed_dispatcher_spec.rb +3 -3
- data/spec/lib/solidus_subscriptions/dispatcher/success_dispatcher_spec.rb +3 -3
- data/spec/lib/solidus_subscriptions/subscription_generator_spec.rb +1 -1
- data/spec/models/solidus_subscriptions/installment_spec.rb +1 -1
- data/spec/models/solidus_subscriptions/subscription_spec.rb +893 -16
- data/spec/models/spree/wallet_payment_source_spec.rb +3 -3
- data/spec/requests/api/v1/subscriptions_spec.rb +229 -0
- data/spec/subscribers/solidus_subscriptions/churn_buster_subscriber_spec.rb +8 -8
- data/spec/subscribers/solidus_subscriptions/order_subscriber_spec.rb +13 -0
- metadata +24 -17
- data/app/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions.rb +0 -25
- data/config/initializers/subscribers.rb +0 -9
- data/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb +0 -32
- /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('
|
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(
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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:
|
11
|
+
date: 2023-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: '2.11'
|
62
62
|
- - "<"
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '4'
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
requirements:
|
69
69
|
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: 2.
|
71
|
+
version: '2.11'
|
72
72
|
- - "<"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '4'
|
@@ -78,14 +78,14 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '0.
|
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.
|
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"
|
@@ -243,7 +244,6 @@ files:
|
|
243
244
|
- app/controllers/spree/admin/users/subscriptions_controller.rb
|
244
245
|
- app/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association.rb
|
245
246
|
- app/decorators/models/solidus_subscriptions/spree/order/after_create.rb
|
246
|
-
- app/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions.rb
|
247
247
|
- app/decorators/models/solidus_subscriptions/spree/order/installment_details_association.rb
|
248
248
|
- app/decorators/models/solidus_subscriptions/spree/order/subscription_association.rb
|
249
249
|
- app/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association.rb
|
@@ -252,6 +252,7 @@ files:
|
|
252
252
|
- app/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions.rb
|
253
253
|
- app/decorators/models/solidus_subscriptions/spree/variant/variant_pretty_name.rb
|
254
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
|
255
256
|
- app/jobs/solidus_subscriptions/process_installment_job.rb
|
256
257
|
- app/jobs/solidus_subscriptions/process_subscription_job.rb
|
257
258
|
- app/models/solidus_subscriptions/installment.rb
|
@@ -269,6 +270,7 @@ files:
|
|
269
270
|
- app/overrides/views/subscription_line_item_fields.rb
|
270
271
|
- app/subscribers/solidus_subscriptions/churn_buster_subscriber.rb
|
271
272
|
- app/subscribers/solidus_subscriptions/event_storage_subscriber.rb
|
273
|
+
- app/subscribers/solidus_subscriptions/order_subscriber.rb
|
272
274
|
- app/views/spree/admin/installments/_state_pill.html.erb
|
273
275
|
- app/views/spree/admin/installments/index.html.erb
|
274
276
|
- app/views/spree/admin/products/_subscribable_checkbox.html.erb
|
@@ -291,7 +293,6 @@ files:
|
|
291
293
|
- app/views/spree/admin/users/_subscription_tab.html.erb
|
292
294
|
- app/views/spree/admin/users/subscriptions/index.html.erb
|
293
295
|
- app/views/spree/admin/variants/_subscribable_checkbox.html.erb
|
294
|
-
- app/views/spree/frontend/products/_subscription_line_item_fields.html.erb
|
295
296
|
- bin/console
|
296
297
|
- bin/rails
|
297
298
|
- bin/rails-engine
|
@@ -300,7 +301,6 @@ files:
|
|
300
301
|
- bin/sandbox
|
301
302
|
- bin/setup
|
302
303
|
- config/initializers/permission_sets.rb
|
303
|
-
- config/initializers/subscribers.rb
|
304
304
|
- config/locales/en.yml
|
305
305
|
- config/routes.rb
|
306
306
|
- db/migrate/20160825164850_create_solidus_subscriptions_subscriptions.rb
|
@@ -334,9 +334,12 @@ files:
|
|
334
334
|
- db/migrate/20201123171026_change_actionable_date_to_date.rb
|
335
335
|
- db/migrate/20210205140422_add_currency_to_subscription.rb
|
336
336
|
- db/migrate/20210323165714_update_promotion_rule_names.rb
|
337
|
+
- db/migrate/20210905145955_add_paused_to_subscriptions.rb
|
337
338
|
- lib/decorators/api/controllers/solidus_subscriptions/spree/api/line_items_controller/create_subscription_line_items.rb
|
338
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
|
@@ -357,6 +360,7 @@ files:
|
|
357
360
|
- lib/solidus_subscriptions/permission_sets/default_customer.rb
|
358
361
|
- lib/solidus_subscriptions/permission_sets/subscription_management.rb
|
359
362
|
- lib/solidus_subscriptions/permitted_attributes.rb
|
363
|
+
- lib/solidus_subscriptions/processing_error_handlers/rails_logger.rb
|
360
364
|
- lib/solidus_subscriptions/processor.rb
|
361
365
|
- lib/solidus_subscriptions/subscription_generator.rb
|
362
366
|
- lib/solidus_subscriptions/subscription_line_item_builder.rb
|
@@ -370,6 +374,7 @@ files:
|
|
370
374
|
- lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
|
371
375
|
- lib/solidus_subscriptions/version.rb
|
372
376
|
- lib/tasks/process_subscriptions.rake
|
377
|
+
- lib/views/spree/frontend/products/_subscription_line_item_fields.html.erb
|
373
378
|
- reference/solidus_subscriptions.v1.yaml
|
374
379
|
- solidus_subscriptions.gemspec
|
375
380
|
- spec/controllers/spree/admin/subscriptions_controller_spec.rb
|
@@ -378,7 +383,6 @@ files:
|
|
378
383
|
- spec/controllers/spree/api/users_controller_spec.rb
|
379
384
|
- spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb
|
380
385
|
- spec/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association_spec.rb
|
381
|
-
- spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb
|
382
386
|
- spec/decorators/models/solidus_subscriptions/spree/order/installment_details_association_spec.rb
|
383
387
|
- spec/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association_spec.rb
|
384
388
|
- spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb
|
@@ -387,6 +391,7 @@ files:
|
|
387
391
|
- spec/features/admin/subscriptions_spec.rb
|
388
392
|
- spec/features/admin_users_subscription_tabs_spec.rb
|
389
393
|
- spec/fixtures/cassettes/churn_buster.yml
|
394
|
+
- spec/jobs/solidus_subscriptions/create_subscription_job_spec.rb
|
390
395
|
- spec/jobs/solidus_subscriptions/process_installment_job_spec.rb
|
391
396
|
- spec/jobs/solidus_subscriptions/process_subscription_job_spec.rb
|
392
397
|
- spec/lib/solidus_subscriptions/checkout_spec.rb
|
@@ -412,6 +417,7 @@ files:
|
|
412
417
|
- spec/requests/api/v1/subscriptions_spec.rb
|
413
418
|
- spec/spec_helper.rb
|
414
419
|
- spec/subscribers/solidus_subscriptions/churn_buster_subscriber_spec.rb
|
420
|
+
- spec/subscribers/solidus_subscriptions/order_subscriber_spec.rb
|
415
421
|
- spec/support/active_model_mocks.rb
|
416
422
|
- spec/support/cancancan.rb
|
417
423
|
- spec/support/factories.rb
|
@@ -421,20 +427,20 @@ files:
|
|
421
427
|
- spec/support/timecop.rb
|
422
428
|
- spec/support/vcr.rb
|
423
429
|
- spec/support/version_cake.rb
|
424
|
-
homepage: https://github.com/solidusio
|
430
|
+
homepage: https://github.com/solidusio/solidus_subscriptions
|
425
431
|
licenses:
|
426
432
|
- BSD-3-Clause
|
427
433
|
metadata:
|
428
|
-
homepage_uri: https://github.com/solidusio
|
429
|
-
source_code_uri: https://github.com/solidusio
|
430
|
-
changelog_uri: https://github.com/solidusio
|
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
|
431
437
|
post_install_message:
|
432
438
|
rdoc_options: []
|
433
439
|
require_paths:
|
434
440
|
- lib
|
435
441
|
required_ruby_version: !ruby/object:Gem::Requirement
|
436
442
|
requirements:
|
437
|
-
- - "
|
443
|
+
- - ">="
|
438
444
|
- !ruby/object:Gem::Version
|
439
445
|
version: '2.5'
|
440
446
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -443,7 +449,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
443
449
|
- !ruby/object:Gem::Version
|
444
450
|
version: '0'
|
445
451
|
requirements: []
|
446
|
-
rubygems_version: 3.
|
452
|
+
rubygems_version: 3.3.7
|
447
453
|
signing_key:
|
448
454
|
specification_version: 4
|
449
455
|
summary: Add subscription support to Solidus
|
@@ -454,7 +460,6 @@ test_files:
|
|
454
460
|
- spec/controllers/spree/api/users_controller_spec.rb
|
455
461
|
- spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb
|
456
462
|
- spec/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association_spec.rb
|
457
|
-
- spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb
|
458
463
|
- spec/decorators/models/solidus_subscriptions/spree/order/installment_details_association_spec.rb
|
459
464
|
- spec/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association_spec.rb
|
460
465
|
- spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb
|
@@ -463,6 +468,7 @@ test_files:
|
|
463
468
|
- spec/features/admin/subscriptions_spec.rb
|
464
469
|
- spec/features/admin_users_subscription_tabs_spec.rb
|
465
470
|
- spec/fixtures/cassettes/churn_buster.yml
|
471
|
+
- spec/jobs/solidus_subscriptions/create_subscription_job_spec.rb
|
466
472
|
- spec/jobs/solidus_subscriptions/process_installment_job_spec.rb
|
467
473
|
- spec/jobs/solidus_subscriptions/process_subscription_job_spec.rb
|
468
474
|
- spec/lib/solidus_subscriptions/checkout_spec.rb
|
@@ -488,6 +494,7 @@ test_files:
|
|
488
494
|
- spec/requests/api/v1/subscriptions_spec.rb
|
489
495
|
- spec/spec_helper.rb
|
490
496
|
- spec/subscribers/solidus_subscriptions/churn_buster_subscriber_spec.rb
|
497
|
+
- spec/subscribers/solidus_subscriptions/order_subscriber_spec.rb
|
491
498
|
- spec/support/active_model_mocks.rb
|
492
499
|
- spec/support/cancancan.rb
|
493
500
|
- spec/support/factories.rb
|
data/app/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions.rb
DELETED
@@ -1,25 +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
|
-
reload
|
17
|
-
|
18
|
-
super
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
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
|
data/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb
DELETED
@@ -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.subscription.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
|
File without changes
|