solidus_subscriptions 1.0.0.rc1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45719f0e107935ab6aa80a88c77f9a4e4724c75a6232d5b48522cbdd46fe1b13
4
- data.tar.gz: 9703884d1d0f90d6eb580df7c33e74c0f90cf5809b9377c237edeef4883a8f84
3
+ metadata.gz: 77254a24d5d35be4a22fe74a9287f2c6ce89c8940327dbf207f93cbda65ac0c3
4
+ data.tar.gz: 3e9d2b8bf25c12e47581281de6e3b659eb0951452030304be5de10f78b781388
5
5
  SHA512:
6
- metadata.gz: cadc2b4bd51ae07326c4a0259c16c70dcce339a672630fd5e6aa8f5e56a47b88d86ce325db6f7c4cb5d36140fef3ac51311660c7a2449b7026b6e23bbdd411ad
7
- data.tar.gz: 3bbd14e0dff7851badd900cf605d25a5468822aff5ab4fb18e2707577c4db0c582db02ac594545747b66831b1a5d3e9d7cf8e8f408499cdb8c3c16a931e30473
6
+ metadata.gz: 5bdb4af6b9b67879b7cb487053ce43ae0cdddcdeec0f4aea0728c177b65b7f9f1f79fae7ae866512d8b1ccc5bc1fb9620eb60bb5bb1352ecfaecb8b61816003c
7
+ data.tar.gz: 58ca346aa4a7bda38c126444fb4de00e5692f9902f4bfc7c34e408addc03cc6fc331c161a5ee3553829d89d50204769591168ebf3232073509bc7539130a9522
data/CHANGELOG.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Changelog
2
2
 
3
- ## [v1.0.0.rc1](https://github.com/solidusio-contrib/solidus_subscriptions/tree/v1.0.0.rc1) (2021-04-02)
3
+ ## [v1.0.0](https://github.com/solidusio-contrib/solidus_subscriptions/tree/v1.0.0) (2021-05-16)
4
4
 
5
- [Full Changelog](https://github.com/solidusio-contrib/solidus_subscriptions/compare/a8a92654ba21b22bd3f8d07c3ae25e3604e7942a...v1.0.0.rc1)
5
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_subscriptions/compare/a8a92654ba21b22bd3f8d07c3ae25e3604e7942a...v1.0.0)
6
6
 
7
7
  **Breaking changes:**
8
8
 
@@ -80,6 +80,7 @@
80
80
 
81
81
  **Closed issues:**
82
82
 
83
+ - Dependabot can't resolve your Ruby dependency files [\#226](https://github.com/solidusio-contrib/solidus_subscriptions/issues/226)
83
84
  - Fix sandbox generation [\#196](https://github.com/solidusio-contrib/solidus_subscriptions/issues/196)
84
85
  - Dependabot can't resolve your Ruby dependency files [\#187](https://github.com/solidusio-contrib/solidus_subscriptions/issues/187)
85
86
  - Dependabot can't resolve your Ruby dependency files [\#186](https://github.com/solidusio-contrib/solidus_subscriptions/issues/186)
@@ -111,6 +112,11 @@
111
112
 
112
113
  **Merged pull requests:**
113
114
 
115
+ - Introduce Installment OrderCreator configuration [\#229](https://github.com/solidusio-contrib/solidus_subscriptions/pull/229) ([cesartalves](https://github.com/cesartalves))
116
+ - Update solidus\_core requirement from \>= 2.0.0, \< 3 to \>= 2.0.0, \< 4 [\#225](https://github.com/solidusio-contrib/solidus_subscriptions/pull/225) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
117
+ - Fix Api Subscription Permitted LineItem Attributes [\#223](https://github.com/solidusio-contrib/solidus_subscriptions/pull/223) ([cesartalves](https://github.com/cesartalves))
118
+ - Fix Spree::OrdersController decoration [\#221](https://github.com/solidusio-contrib/solidus_subscriptions/pull/221) ([cesartalves](https://github.com/cesartalves))
119
+ - Reload order during finalize action [\#220](https://github.com/solidusio-contrib/solidus_subscriptions/pull/220) ([seand7565](https://github.com/seand7565))
114
120
  - Update specs to conform with rubocop [\#217](https://github.com/solidusio-contrib/solidus_subscriptions/pull/217) ([seand7565](https://github.com/seand7565))
115
121
  - Update promotion rule names on db [\#216](https://github.com/solidusio-contrib/solidus_subscriptions/pull/216) ([luca-landa](https://github.com/luca-landa))
116
122
  - Improve promotion rules names [\#215](https://github.com/solidusio-contrib/solidus_subscriptions/pull/215) ([luca-landa](https://github.com/luca-landa))
@@ -78,7 +78,7 @@ module SolidusSubscriptions
78
78
  end
79
79
 
80
80
  def line_item_attributes
81
- SolidusSubscriptions.configuration.subscription_line_item_attributes - [:subscribable_id] + [:id]
81
+ SolidusSubscriptions.configuration.subscription_line_item_attributes
82
82
  end
83
83
 
84
84
  def update_payment_attributes(attributes)
@@ -13,6 +13,8 @@ module SolidusSubscriptions
13
13
  SolidusSubscriptions::SubscriptionGenerator.activate(line_items)
14
14
  end
15
15
 
16
+ reload
17
+
16
18
  super
17
19
  end
18
20
  end
@@ -12,9 +12,9 @@ module SolidusSubscriptions
12
12
  def remove_from_subscriptions
13
13
  SolidusSubscriptions::LineItem.where(subscribable: self).delete_all
14
14
  end
15
+
16
+ ::Spree::Variant.prepend self
15
17
  end
16
18
  end
17
19
  end
18
20
  end
19
-
20
- Spree::Variant.prepend(SolidusSubscriptions::Spree::Variant::AutoDeleteFromSubscriptions)
@@ -96,4 +96,17 @@ SolidusSubscriptions.configure do |config|
96
96
  # with new subscription cycles by clearing any past failed installment when a new one is created
97
97
 
98
98
  # config.clear_past_installments = true
99
+
100
+ # ==================================== Custom Order Creation =====================================
101
+ #
102
+ # This settings allows the customization of the creation of each Installment Order by means of
103
+ # providing a class that can be switched / inherited
104
+ #
105
+ #
106
+ # the order_creator_class is initialized and called on the creation of the Order for each Subscription
107
+ # Installment.
108
+ # If you want to add simple extra attributes to the Order (such as a channel), that can be done by
109
+ # overriding the `extra_attributes` method on a subclass
110
+ #
111
+ # config.order_creator_class = 'SolidusSubscriptions::OrderCreator'
99
112
  end
@@ -26,6 +26,7 @@ require 'solidus_subscriptions/dispatcher/failure_dispatcher'
26
26
  require 'solidus_subscriptions/dispatcher/out_of_stock_dispatcher'
27
27
  require 'solidus_subscriptions/dispatcher/payment_failed_dispatcher'
28
28
  require 'solidus_subscriptions/dispatcher/success_dispatcher'
29
+ require 'solidus_subscriptions/order_creator'
29
30
 
30
31
  module SolidusSubscriptions
31
32
  class << self
@@ -32,14 +32,7 @@ module SolidusSubscriptions
32
32
  private
33
33
 
34
34
  def create_order
35
- ::Spree::Order.create(
36
- user: installment.subscription.user,
37
- email: installment.subscription.user.email,
38
- store: installment.subscription.store || ::Spree::Store.default,
39
- subscription_order: true,
40
- subscription: installment.subscription,
41
- currency: installment.subscription.currency
42
- )
35
+ SolidusSubscriptions.configuration.order_creator_class.new(installment).call
43
36
  end
44
37
 
45
38
  def populate_order(order)
@@ -61,7 +54,7 @@ module SolidusSubscriptions
61
54
  order.payments.create(
62
55
  payment_method: installment.subscription.payment_method_to_use,
63
56
  source: installment.subscription.payment_source_to_use,
64
- amount: order.total,
57
+ amount: order.total
65
58
  )
66
59
  end
67
60
 
@@ -4,14 +4,14 @@ module SolidusSubscriptions
4
4
  class Configuration
5
5
  attr_accessor(
6
6
  :maximum_total_skips, :maximum_reprocessing_time, :churn_buster_account_id,
7
- :churn_buster_api_key, :clear_past_installments, :processing_error_handler,
7
+ :churn_buster_api_key, :clear_past_installments, :processing_error_handler
8
8
  )
9
9
 
10
10
  attr_writer(
11
11
  :success_dispatcher_class, :failure_dispatcher_class, :payment_failed_dispatcher_class,
12
12
  :out_of_stock_dispatcher, :maximum_successive_skips, :reprocessing_interval,
13
13
  :minimum_cancellation_notice, :processing_queue, :subscription_line_item_attributes,
14
- :subscription_attributes, :subscribable_class,
14
+ :subscription_attributes, :subscribable_class, :order_creator_class
15
15
  )
16
16
 
17
17
  def success_dispatcher_class
@@ -52,11 +52,12 @@ module SolidusSubscriptions
52
52
 
53
53
  def subscription_line_item_attributes
54
54
  @subscription_line_item_attributes ||= [
55
+ :id,
55
56
  :quantity,
56
57
  :subscribable_id,
57
58
  :interval_length,
58
59
  :interval_units,
59
- :end_date,
60
+ :end_date
60
61
  ]
61
62
  end
62
63
 
@@ -68,7 +69,7 @@ module SolidusSubscriptions
68
69
  {
69
70
  shipping_address_attributes: Spree::PermittedAttributes.address_attributes,
70
71
  billing_address_attributes: Spree::PermittedAttributes.address_attributes
71
- },
72
+ }
72
73
  ]
73
74
  end
74
75
 
@@ -80,5 +81,10 @@ module SolidusSubscriptions
80
81
  def churn_buster?
81
82
  churn_buster_account_id.present? && churn_buster_api_key.present?
82
83
  end
84
+
85
+ def order_creator_class
86
+ @order_creator_class ||= 'SolidusSubscriptions::OrderCreator'
87
+ @order_creator_class.constantize
88
+ end
83
89
  end
84
90
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusSubscriptions
4
+ class OrderCreator
5
+ def initialize(installment)
6
+ @installment = installment
7
+ end
8
+
9
+ def call
10
+ ::Spree::Order.create(
11
+ user: installment.subscription.user,
12
+ email: installment.subscription.user.email,
13
+ store: installment.subscription.store || ::Spree::Store.default,
14
+ subscription_order: true,
15
+ subscription: installment.subscription,
16
+ currency: installment.subscription.currency,
17
+ **extra_attributes
18
+ )
19
+ end
20
+
21
+ private
22
+
23
+ def extra_attributes
24
+ {}
25
+ end
26
+
27
+ attr_reader :installment
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusSubscriptions
4
- VERSION = '1.0.0.rc1'
4
+ VERSION = '1.0.0'
5
5
  end
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency 'deface'
33
33
  spec.add_dependency 'httparty', '~> 0.18'
34
34
  spec.add_dependency 'i18n'
35
- spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 3']
35
+ spec.add_dependency 'solidus_core', '>= 2.0.0', '< 4'
36
36
  spec.add_dependency 'solidus_support', '~> 0.7'
37
37
  spec.add_dependency 'state_machines'
38
38
 
@@ -8,7 +8,7 @@ RSpec.describe SolidusSubscriptions::Spree::Order::FinalizeCreatesSubscriptions
8
8
 
9
9
  let(:order) { create :order, :with_subscription_line_items }
10
10
  let(:subscription_line_item) { order.subscription_line_items.last }
11
- let(:expected_actionable_date) { Time.zone.today + subscription_line_item.interval }
11
+ let(:expected_actionable_date) { Time.zone.today + subscription_line_item.subscription.interval }
12
12
 
13
13
  around { |e| Timecop.freeze { e.run } }
14
14
 
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.0
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: 2021-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -61,7 +61,7 @@ dependencies:
61
61
  version: 2.0.0
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
@@ -71,7 +71,7 @@ dependencies:
71
71
  version: 2.0.0
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
@@ -241,8 +241,6 @@ files:
241
241
  - app/controllers/spree/admin/subscription_orders_controller.rb
242
242
  - app/controllers/spree/admin/subscriptions_controller.rb
243
243
  - 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
244
  - app/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association.rb
247
245
  - app/decorators/models/solidus_subscriptions/spree/order/after_create.rb
248
246
  - app/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions.rb
@@ -336,6 +334,8 @@ 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
+ - lib/decorators/api/controllers/solidus_subscriptions/spree/api/line_items_controller/create_subscription_line_items.rb
338
+ - lib/decorators/frontend/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items.rb
339
339
  - lib/generators/solidus_subscriptions/install/install_generator.rb
340
340
  - lib/generators/solidus_subscriptions/install/templates/initializer.rb
341
341
  - lib/solidus_subscriptions.rb
@@ -353,6 +353,7 @@ files:
353
353
  - lib/solidus_subscriptions/dispatcher/payment_failed_dispatcher.rb
354
354
  - lib/solidus_subscriptions/dispatcher/success_dispatcher.rb
355
355
  - lib/solidus_subscriptions/engine.rb
356
+ - lib/solidus_subscriptions/order_creator.rb
356
357
  - lib/solidus_subscriptions/permission_sets/default_customer.rb
357
358
  - lib/solidus_subscriptions/permission_sets/subscription_management.rb
358
359
  - lib/solidus_subscriptions/permitted_attributes.rb
@@ -438,11 +439,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
438
439
  version: '2.5'
439
440
  required_rubygems_version: !ruby/object:Gem::Requirement
440
441
  requirements:
441
- - - ">"
442
+ - - ">="
442
443
  - !ruby/object:Gem::Version
443
- version: 1.3.1
444
+ version: '0'
444
445
  requirements: []
445
- rubygems_version: 3.0.3
446
+ rubygems_version: 3.0.8
446
447
  signing_key:
447
448
  specification_version: 4
448
449
  summary: Add subscription support to Solidus