solidus_core 2.11.1 → 3.0.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of solidus_core might be problematic. Click here for more details.

Files changed (198) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree.js.erb +0 -51
  3. data/app/helpers/spree/store_helper.rb +0 -11
  4. data/app/mailers/spree/carton_mailer.rb +1 -5
  5. data/app/models/concerns/spree/adjustment_source.rb +0 -15
  6. data/app/models/concerns/spree/calculated_adjustments.rb +0 -18
  7. data/app/models/concerns/spree/soft_deletable.rb +2 -4
  8. data/app/models/concerns/spree/user_address_book.rb +0 -37
  9. data/app/models/concerns/spree/user_methods.rb +2 -11
  10. data/app/models/spree/ability.rb +0 -37
  11. data/app/models/spree/address.rb +7 -162
  12. data/app/models/spree/address/name.rb +2 -20
  13. data/app/models/spree/adjustment.rb +0 -28
  14. data/app/models/spree/base.rb +1 -12
  15. data/app/models/spree/calculator.rb +4 -11
  16. data/app/models/spree/calculator/flexi_rate.rb +0 -5
  17. data/app/models/spree/country.rb +1 -6
  18. data/app/models/spree/credit_card.rb +0 -27
  19. data/app/models/spree/customer_return.rb +1 -4
  20. data/app/models/spree/image.rb +0 -7
  21. data/app/models/spree/inventory_unit.rb +0 -21
  22. data/app/models/spree/line_item.rb +2 -45
  23. data/app/models/spree/order.rb +3 -136
  24. data/app/models/spree/order/payments.rb +2 -2
  25. data/app/models/spree/order_cancellations.rb +4 -24
  26. data/app/models/spree/order_merger.rb +1 -1
  27. data/app/models/spree/order_updater.rb +2 -11
  28. data/app/models/spree/payment.rb +10 -6
  29. data/app/models/spree/payment/cancellation.rb +3 -22
  30. data/app/models/spree/payment_create.rb +1 -13
  31. data/app/models/spree/payment_method.rb +2 -103
  32. data/app/models/spree/payment_method/credit_card.rb +1 -3
  33. data/app/models/spree/payment_source.rb +2 -2
  34. data/app/models/spree/product.rb +8 -41
  35. data/app/models/spree/product/scopes.rb +0 -28
  36. data/app/models/spree/promotion.rb +2 -6
  37. data/app/models/spree/promotion/actions/create_adjustment.rb +0 -3
  38. data/app/models/spree/promotion/actions/create_item_adjustments.rb +0 -3
  39. data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +0 -3
  40. data/app/models/spree/promotion/rules/taxon.rb +2 -15
  41. data/app/models/spree/promotion_action.rb +2 -9
  42. data/app/models/spree/promotion_code/batch_builder.rb +0 -14
  43. data/app/models/spree/refund.rb +3 -47
  44. data/app/models/spree/reimbursement.rb +3 -41
  45. data/app/models/spree/reimbursement_performer.rb +2 -8
  46. data/app/models/spree/reimbursement_type/credit.rb +1 -4
  47. data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +1 -2
  48. data/app/models/spree/reimbursement_type/store_credit.rb +1 -4
  49. data/app/models/spree/return_authorization.rb +1 -4
  50. data/app/models/spree/return_item.rb +1 -19
  51. data/app/models/spree/shipment.rb +1 -54
  52. data/app/models/spree/shipping_method.rb +1 -26
  53. data/app/models/spree/shipping_rate.rb +0 -2
  54. data/app/models/spree/state.rb +0 -4
  55. data/app/models/spree/stock/availability_validator.rb +2 -2
  56. data/app/models/spree/stock/inventory_validator.rb +2 -2
  57. data/app/models/spree/stock/simple_coordinator.rb +0 -14
  58. data/app/models/spree/stock/splitter/base.rb +2 -7
  59. data/app/models/spree/stock_item.rb +1 -7
  60. data/app/models/spree/store.rb +0 -12
  61. data/app/models/spree/store_credit_category.rb +0 -32
  62. data/app/models/spree/tax_calculator/shipping_rate.rb +1 -12
  63. data/app/models/spree/tax_rate.rb +0 -27
  64. data/app/models/spree/taxon.rb +0 -11
  65. data/app/models/spree/taxon/active_storage_attachment.rb +0 -6
  66. data/app/models/spree/taxon/paperclip_attachment.rb +0 -4
  67. data/app/models/spree/user_address.rb +0 -5
  68. data/app/models/spree/variant.rb +1 -45
  69. data/config/locales/en.yml +0 -8
  70. data/db/migrate/20210122110141_add_name_to_spree_addresses.rb +13 -0
  71. data/lib/generators/solidus/install/install_generator.rb +12 -1
  72. data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +3 -39
  73. data/lib/generators/spree/dummy/dummy_generator.rb +2 -1
  74. data/lib/generators/spree/dummy/templates/rails/database.yml +6 -1
  75. data/lib/generators/spree/dummy/templates/rails/storage.yml +3 -0
  76. data/lib/generators/spree/dummy/templates/rails/test.rb +6 -1
  77. data/lib/spree/app_configuration.rb +7 -66
  78. data/lib/spree/core.rb +10 -12
  79. data/lib/spree/core/class_constantizer.rb +2 -0
  80. data/lib/spree/core/controller_helpers/auth.rb +1 -14
  81. data/lib/spree/core/controller_helpers/order.rb +2 -22
  82. data/lib/spree/core/controller_helpers/payment_parameters.rb +0 -54
  83. data/lib/spree/core/controller_helpers/pricing.rb +0 -8
  84. data/lib/spree/core/controller_helpers/strong_parameters.rb +0 -4
  85. data/lib/spree/core/engine.rb +6 -42
  86. data/lib/spree/core/environment_extension.rb +0 -9
  87. data/lib/spree/core/product_filters.rb +0 -40
  88. data/lib/spree/core/role_configuration.rb +0 -14
  89. data/lib/spree/core/search/base.rb +0 -26
  90. data/lib/spree/core/state_machines.rb +2 -11
  91. data/lib/spree/core/version.rb +1 -1
  92. data/lib/spree/event.rb +0 -31
  93. data/lib/spree/event/configuration.rb +0 -5
  94. data/lib/spree/event/subscriber.rb +0 -18
  95. data/lib/spree/event/subscriber_registry.rb +3 -1
  96. data/lib/spree/i18n.rb +0 -22
  97. data/lib/spree/money.rb +3 -18
  98. data/lib/spree/permitted_attributes.rb +2 -53
  99. data/lib/spree/testing_support.rb +31 -0
  100. data/lib/spree/testing_support/capybara_ext.rb +0 -30
  101. data/lib/spree/testing_support/controller_requests.rb +0 -82
  102. data/lib/spree/testing_support/dummy_app.rb +10 -16
  103. data/lib/spree/testing_support/dummy_app/mailer_previews/test_mailer_preview.rb +4 -0
  104. data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
  105. data/lib/spree/testing_support/factories.rb +8 -4
  106. data/lib/spree/testing_support/factories/address_factory.rb +6 -2
  107. data/lib/spree/testing_support/factories/adjustment_factory.rb +10 -5
  108. data/lib/spree/testing_support/factories/adjustment_reason_factory.rb +5 -0
  109. data/lib/spree/testing_support/factories/calculator_factory.rb +5 -0
  110. data/lib/spree/testing_support/factories/carton_factory.rb +7 -2
  111. data/lib/spree/testing_support/factories/country_factory.rb +5 -0
  112. data/lib/spree/testing_support/factories/credit_card_factory.rb +5 -0
  113. data/lib/spree/testing_support/factories/customer_return_factory.rb +8 -3
  114. data/lib/spree/testing_support/factories/image_factory.rb +5 -0
  115. data/lib/spree/testing_support/factories/inventory_unit_factory.rb +9 -4
  116. data/lib/spree/testing_support/factories/line_item_factory.rb +7 -2
  117. data/lib/spree/testing_support/factories/option_type_factory.rb +8 -0
  118. data/lib/spree/testing_support/factories/option_value_factory.rb +5 -0
  119. data/lib/spree/testing_support/factories/order_factory.rb +11 -7
  120. data/lib/spree/testing_support/factories/order_promotion_factory.rb +7 -2
  121. data/lib/spree/testing_support/factories/payment_factory.rb +9 -4
  122. data/lib/spree/testing_support/factories/payment_method_factory.rb +5 -0
  123. data/lib/spree/testing_support/factories/price_factory.rb +6 -1
  124. data/lib/spree/testing_support/factories/product_factory.rb +10 -5
  125. data/lib/spree/testing_support/factories/product_option_type_factory.rb +7 -2
  126. data/lib/spree/testing_support/factories/product_property_factory.rb +7 -2
  127. data/lib/spree/testing_support/factories/promotion_category_factory.rb +5 -0
  128. data/lib/spree/testing_support/factories/promotion_code_factory.rb +7 -2
  129. data/lib/spree/testing_support/factories/promotion_factory.rb +7 -2
  130. data/lib/spree/testing_support/factories/property_factory.rb +5 -0
  131. data/lib/spree/testing_support/factories/refund_factory.rb +7 -3
  132. data/lib/spree/testing_support/factories/refund_reason_factory.rb +5 -0
  133. data/lib/spree/testing_support/factories/reimbursement_factory.rb +6 -1
  134. data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +5 -0
  135. data/lib/spree/testing_support/factories/return_authorization_factory.rb +8 -3
  136. data/lib/spree/testing_support/factories/return_item_factory.rb +8 -3
  137. data/lib/spree/testing_support/factories/return_reason_factory.rb +5 -0
  138. data/lib/spree/testing_support/factories/role_factory.rb +5 -0
  139. data/lib/spree/testing_support/factories/shipment_factory.rb +9 -3
  140. data/lib/spree/testing_support/factories/shipping_category_factory.rb +5 -0
  141. data/lib/spree/testing_support/factories/shipping_method_factory.rb +8 -3
  142. data/lib/spree/testing_support/factories/shipping_rate_factory.rb +7 -2
  143. data/lib/spree/testing_support/factories/state_factory.rb +7 -1
  144. data/lib/spree/testing_support/factories/stock_item_factory.rb +7 -2
  145. data/lib/spree/testing_support/factories/stock_location_factory.rb +8 -3
  146. data/lib/spree/testing_support/factories/stock_movement_factory.rb +6 -1
  147. data/lib/spree/testing_support/factories/stock_package_factory.rb +7 -2
  148. data/lib/spree/testing_support/factories/store_credit_category_factory.rb +5 -0
  149. data/lib/spree/testing_support/factories/store_credit_event_factory.rb +7 -2
  150. data/lib/spree/testing_support/factories/store_credit_factory.rb +8 -3
  151. data/lib/spree/testing_support/factories/store_credit_reason_factory.rb +5 -0
  152. data/lib/spree/testing_support/factories/store_credit_type_factory.rb +5 -0
  153. data/lib/spree/testing_support/factories/store_factory.rb +6 -1
  154. data/lib/spree/testing_support/factories/tax_category_factory.rb +7 -1
  155. data/lib/spree/testing_support/factories/tax_rate_factory.rb +8 -3
  156. data/lib/spree/testing_support/factories/taxon_factory.rb +6 -1
  157. data/lib/spree/testing_support/factories/taxonomy_factory.rb +5 -0
  158. data/lib/spree/testing_support/factories/user_factory.rb +8 -3
  159. data/lib/spree/testing_support/factories/variant_factory.rb +9 -4
  160. data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +7 -2
  161. data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +8 -3
  162. data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +7 -2
  163. data/lib/spree/testing_support/factories/zone_factory.rb +7 -2
  164. data/lib/spree/testing_support/factory_bot.rb +68 -0
  165. data/lib/spree/testing_support/order_walkthrough.rb +10 -13
  166. data/lib/spree/testing_support/preferences.rb +0 -25
  167. data/lib/spree/testing_support/sequences.rb +4 -1
  168. data/{app/models → lib}/spree/user_class_handle.rb +0 -0
  169. data/lib/tasks/migrations/migrate_address_names.rake +158 -0
  170. data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +38 -0
  171. data/lib/tasks/upgrade.rake +13 -0
  172. data/solidus_core.gemspec +3 -4
  173. metadata +32 -63
  174. data/app/mailers/spree/test_mailer.rb +0 -13
  175. data/app/models/concerns/spree/user_payment_source.rb +0 -26
  176. data/app/models/spree/calculator/free_shipping.rb +0 -21
  177. data/app/models/spree/calculator/percent_per_item.rb +0 -49
  178. data/app/models/spree/calculator/price_sack.rb +0 -27
  179. data/app/models/spree/gateway.rb +0 -14
  180. data/app/models/spree/gateway/bogus.rb +0 -13
  181. data/app/models/spree/gateway/bogus_simple.rb +0 -13
  182. data/app/models/spree/order/checkout.rb +0 -244
  183. data/app/models/spree/order_capturing.rb +0 -50
  184. data/app/models/spree/promotion_handler/free_shipping.rb +0 -9
  185. data/lib/generators/spree/install/install_generator.rb +0 -15
  186. data/lib/solidus/migrations/rename_gateways.rb +0 -41
  187. data/lib/spree/awesome_nested_set_override.rb +0 -44
  188. data/lib/spree/core/current_store.rb +0 -24
  189. data/lib/spree/paranoia_deprecations.rb +0 -41
  190. data/lib/spree/promo/environment.rb +0 -12
  191. data/lib/spree/testing_support/bar_ability.rb +0 -19
  192. data/lib/tasks/core.rake +0 -104
  193. data/lib/tasks/email.rake +0 -11
  194. data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +0 -119
  195. data/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +0 -22
  196. data/lib/tasks/migrations/migrate_user_addresses.rake +0 -34
  197. data/lib/tasks/migrations/rename_gateways.rake +0 -23
  198. data/lib/tasks/order_capturing.rake +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27c649d69898f48beb004c4fdb16d78dada64e38f8165931954f2cbc51b25574
4
- data.tar.gz: 62e64ebb11e212cb59e99d0917d30ba96bdbaaa01b7e1c94f20f0767c455ce5c
3
+ metadata.gz: 35ced6fd29e1822a14a86b637243c871d373b2ead2d575e7737d0fa35907a48d
4
+ data.tar.gz: ab72677886bf4ce7c2ba48dbe711fe73aa5e1193d990fb4d7cd872035e247f33
5
5
  SHA512:
6
- metadata.gz: 3f9f71f775c454060561150333623dbd59721174f9d930fce288c85262384f3504ce72ee6b3b0e7575c6d8745f0e289d938662c99f5ff91f0a2655ff2198e4ea
7
- data.tar.gz: '08c0e6a2a2d1664f3b49919ad56327ae5e4e0f80e2bdbb31d4a86df91cab1b270e10aa2bc255309ee2b8b67c7cdaa1f7adca135e46fca8aef833bdf40d15bbbf'
6
+ metadata.gz: 1b18d6067bfbe97ce226fd82fb9a48da5e16eadeef3ac3b758c7d159dc079aef8880396a2acb9c0e23f98953d331f8161ba3271f780c21de04c1f9e501b1136b
7
+ data.tar.gz: 5cc4ad46294a842daa2850e785d08dbfa4f01b28f5806449457fb498898c557866590ed7d332888d6c5fae72ae1ee81fbf3d4fa1ead5aa682af226debce6a890
@@ -22,21 +22,6 @@ Spree.pathFor = function(path) {
22
22
  return locationOrigin + Spree.mountedAt() + path;
23
23
  };
24
24
 
25
- Spree.url = function(uri, query) {
26
- if (console && console.warn) {
27
- console.warn('Spree.url is deprecated, and will be removed from a future Solidus version.');
28
- }
29
- if (uri.path === undefined) {
30
- uri = new Uri(uri);
31
- }
32
- if (query) {
33
- $.each(query, function(key, value) {
34
- return uri.addQueryParam(key, value);
35
- });
36
- }
37
- return uri;
38
- };
39
-
40
25
  Spree.ajax = function(url, options) {
41
26
  if (typeof url === "object") {
42
27
  options = url;
@@ -51,42 +36,6 @@ Spree.ajax = function(url, options) {
51
36
  return $.ajax(url, options);
52
37
  };
53
38
 
54
- /**
55
- * @deprecated Spree.routes will be removed in a future release. Please use Spree.pathFor instead.
56
- * See: https://github.com/solidusio/solidus/issues/3405
57
- */
58
- Spree.routesDeprecationProxy = {
59
- get: function(obj, prop) {
60
- <% if Rails.env != "production" %>
61
- console.log("Spree.routes is deprecated, please use pathFor instead. See: https://github.com/solidusio/solidus/issues/3405");
62
- <% end %>
63
-
64
- return obj[prop]
65
- },
66
-
67
- set: function(obj, prop, value) {
68
- <% if Rails.env != "production" %>
69
- console.log("Spree.routes is deprecated, please use pathFor instead. See: https://github.com/solidusio/solidus/issues/3405");
70
- <% end %>
71
-
72
- obj[prop] = value
73
- return value;
74
- }
75
- };
76
-
77
- var frontend_routes = {
78
- states_search: Spree.pathFor('api/states'),
79
- apply_coupon_code: function(order_id) {
80
- return Spree.pathFor("api/orders/" + order_id + "/coupon_codes");
81
- }
82
- }
83
-
84
- if(typeof Proxy == "function") {
85
- Spree.routes = new Proxy(frontend_routes, Spree.routesDeprecationProxy);
86
- } else {
87
- Spree.routes = frontend_routes
88
- }
89
-
90
39
  Spree.getJSON = function(url, data, success) {
91
40
  if (typeof data === 'function') {
92
41
  success = data;
@@ -8,16 +8,5 @@ module Spree
8
8
  def store_menu?
9
9
  %w{thank_you}.exclude? params[:action]
10
10
  end
11
-
12
- def cache_key_for_taxons
13
- Spree::Deprecation.warn <<-WARN.strip_heredoc
14
- cache_key_for_taxons is deprecated. Rails >= 5 has built-in support for collection cache keys.
15
- Instead in your view use:
16
- cache [I18n.locale, @taxons] do
17
- WARN
18
- max_updated_at = @taxons.maximum(:updated_at).to_i
19
- parts = [@taxon.try(:id), max_updated_at].compact.join("-")
20
- "#{I18n.locale}/taxons/#{parts}"
21
- end
22
11
  end
23
12
  end
@@ -11,11 +11,7 @@ module Spree
11
11
  # @option options resend [Boolean] indicates whether the email is a 'resend' (e.g.
12
12
  # triggered by the admin "resend" button)
13
13
  # @return [Mail::Message]
14
- #
15
- # Note: The signature of this method has changed. The new (non-deprecated)
16
- # signature is:
17
- # def shipped_email(carton:, order:, resend: false)
18
- def shipped_email(options, _deprecated_options = {})
14
+ def shipped_email(options)
19
15
  @order = options.fetch(:order)
20
16
  @carton = options.fetch(:carton)
21
17
  @manifest = @carton.manifest_for_order(@order)
@@ -2,21 +2,6 @@
2
2
 
3
3
  module Spree
4
4
  module AdjustmentSource
5
- def deals_with_adjustments_for_deleted_source
6
- Spree::Deprecation.warn "AdjustmentSource#deals_with_adjustments_for_deleted_source is deprecated. Please use AdjustmentSource#remove_adjustments_from_incomplete_orders instead."
7
-
8
- remove_adjustments_from_incomplete_orders
9
-
10
- # The following is deprecated. As source_type without a source_id isn't
11
- # much better than a source_id that doesn't exist. In Solidus itself the
12
- # relevant classes use `acts_as_paranoid` so it is useful to keep the
13
- # source_id around.
14
- adjustments.
15
- joins(:order).
16
- merge(Spree::Order.complete).
17
- update_all(source_id: nil, updated_at: Time.current)
18
- end
19
-
20
5
  def remove_adjustments_from_incomplete_orders
21
6
  adjustments.
22
7
  joins(:order).
@@ -10,24 +10,6 @@ module Spree
10
10
  validates :calculator, presence: true
11
11
  end
12
12
 
13
- class_methods do
14
- def calculators
15
- Spree::Deprecation.warn("Calling .calculators is deprecated. Please access through Rails.application.config.spree.calculators")
16
-
17
- spree_calculators.send model_name_without_spree_namespace
18
- end
19
-
20
- private
21
-
22
- def model_name_without_spree_namespace
23
- to_s.tableize.tr('/', '_').sub('spree_', '')
24
- end
25
-
26
- def spree_calculators
27
- Spree::Config.environment.calculators
28
- end
29
- end
30
-
31
13
  def calculator_type
32
14
  calculator.class.to_s if calculator
33
15
  end
@@ -7,12 +7,10 @@ module Spree
7
7
  extend ActiveSupport::Concern
8
8
 
9
9
  included do
10
- acts_as_paranoid
11
- include Spree::ParanoiaDeprecations::InstanceMethods
12
- extend Spree::ParanoiaDeprecations::ClassMethods
13
-
14
10
  include Discard::Model
15
11
  self.discard_column = :deleted_at
12
+
13
+ default_scope { kept }
16
14
  end
17
15
  end
18
16
  end
@@ -39,34 +39,6 @@ module Spree
39
39
  has_one :ship_address, through: :default_user_ship_address, source: :address
40
40
  end
41
41
 
42
- def default_address
43
- Spree::Deprecation.warn "#default_address is deprecated. Please start using #ship_address."
44
- ship_address
45
- end
46
-
47
- def default_user_address
48
- Spree::Deprecation.warn "#default_user_address is deprecated. Please start using #default_user_ship_address."
49
- default_user_ship_address
50
- end
51
-
52
- def default_address=(address)
53
- Spree::Deprecation.warn(
54
- "#default_address= does not take Spree::Config.automatic_default_address into account and is deprecated. " \
55
- "Please use #ship_address=."
56
- )
57
-
58
- self.ship_address = address if address
59
- end
60
-
61
- def default_address_attributes=(attributes)
62
- # see "Nested Attributes Examples" section of http://apidock.com/rails/ActionView/Helpers/FormHelper/fields_for
63
- # this #{fieldname}_attributes= method works with fields_for in the views
64
- # even without declaring accepts_nested_attributes_for
65
- Spree::Deprecation.warn "#default_address_attributes= is deprecated. Please use #ship_address_attributes=."
66
-
67
- self.default_address = Spree::Address.immutable_merge(ship_address, attributes)
68
- end
69
-
70
42
  # saves address in address book
71
43
  # sets address to the default if automatic_default_address is set to true
72
44
  # if address is nil, does nothing and returns nil
@@ -157,15 +129,6 @@ module Spree
157
129
  user_address.address
158
130
  end
159
131
 
160
- def mark_default_address(address)
161
- Spree::Deprecation.warn(
162
- "#mark_default_address is deprecated and it sets the ship_address only. " \
163
- "Please use #mark_default_ship_address."
164
- )
165
-
166
- mark_default_ship_address(address)
167
- end
168
-
169
132
  def mark_default_ship_address(address)
170
133
  user_addresses.mark_default(user_addresses.find_by(address: address))
171
134
  end
@@ -7,7 +7,6 @@ module Spree
7
7
  include Spree::UserApiAuthentication
8
8
  include Spree::UserReporting
9
9
  include Spree::UserAddressBook
10
- include Spree::UserPaymentSource
11
10
 
12
11
  included do
13
12
  extend Spree::DisplayMoney
@@ -24,9 +23,6 @@ module Spree
24
23
  has_many :store_credits, -> { includes(:credit_type) }, foreign_key: "user_id", class_name: "Spree::StoreCredit"
25
24
  has_many :store_credit_events, through: :store_credits
26
25
 
27
- money_methods :total_available_store_credit
28
- deprecate display_total_available_store_credit: :display_available_store_credit_total, deprecator: Spree::Deprecation
29
-
30
26
  has_many :credit_cards, class_name: "Spree::CreditCard", foreign_key: :user_id
31
27
  has_many :wallet_payment_sources, foreign_key: 'user_id', class_name: 'Spree::WalletPaymentSource', inverse_of: :user
32
28
 
@@ -34,9 +30,9 @@ module Spree
34
30
 
35
31
  include Spree::RansackableAttributes unless included_modules.include?(Spree::RansackableAttributes)
36
32
 
37
- ransack_alias :firstname_or_lastname, :addresses_firstname_or_addresses_lastname
33
+ ransack_alias :name, :addresses_name
38
34
  self.whitelisted_ransackable_associations = %w[addresses spree_roles]
39
- self.whitelisted_ransackable_attributes = %w[firstname_or_lastname id email created_at]
35
+ self.whitelisted_ransackable_attributes = %w[name id email created_at]
40
36
  end
41
37
 
42
38
  def wallet
@@ -68,11 +64,6 @@ module Spree
68
64
  last_order unless last_order.try!(:completed?)
69
65
  end
70
66
 
71
- def total_available_store_credit
72
- store_credits.reload.to_a.sum(&:amount_remaining)
73
- end
74
- deprecate total_available_store_credit: :available_store_credit_total, deprecator: Spree::Deprecation
75
-
76
67
  def available_store_credit_total(currency:)
77
68
  store_credits.to_a.
78
69
  select { |credit| credit.currency == currency }.
@@ -14,13 +14,6 @@ module Spree
14
14
 
15
15
  attr_reader :user
16
16
 
17
- CUSTOM_ALIASES_MAP = {
18
- delete: :destroy,
19
- display: :read,
20
- new_action: :create,
21
- read: :show
22
- }.freeze
23
-
24
17
  # Allows us to go beyond the standard cancan initialize method which makes it difficult for engines to
25
18
  # modify the default +Ability+ of an application. The +ability+ argument must be a class that includes
26
19
  # the +CanCan::Ability+ module. The registered ability should behave properly as a stand-alone class
@@ -40,38 +33,8 @@ module Spree
40
33
  register_extension_abilities
41
34
  end
42
35
 
43
- def can?(action, *args)
44
- super(normalize_action(action), *args)
45
- end
46
-
47
- def model_adapter(model_class, action)
48
- super(model_class, normalize_action(action))
49
- end
50
-
51
36
  private
52
37
 
53
- def normalize_action(action)
54
- return action unless Spree::Config.use_custom_cancancan_actions
55
-
56
- normalized_action = CUSTOM_ALIASES_MAP.fetch(action, action)
57
-
58
- if action == :read
59
- Spree::Deprecation.warn <<~WARN, caller(3)
60
- The behavior of CanCanCan `:read` action alias will be changing in Solidus 3.0.
61
- The current alias is: `:show, :to => :read`,
62
- the new alias will be compliant with CanCanCan's default: `index, :show, :to => :read`
63
- WARN
64
- elsif CUSTOM_ALIASES_MAP.key? action
65
- Spree::Deprecation.warn <<~WARN, caller(3)
66
- Calling CanCanCan alias action #{action.inspect} is deprecated.
67
- In Solidus 3.0 non-standard CanCanCan action aliases will be replaced with default ones,
68
- please replace with #{normalized_action.inspect}.
69
- WARN
70
- end
71
-
72
- normalized_action
73
- end
74
-
75
38
  # Before, this was the only way to extend this ability. Permission sets have been added since.
76
39
  # It is recommended to use them instead for extension purposes if possible.
77
40
  def register_extension_abilities
@@ -14,45 +14,24 @@ module Spree
14
14
  belongs_to :country, class_name: "Spree::Country", optional: true
15
15
  belongs_to :state, class_name: "Spree::State", optional: true
16
16
 
17
- validates :address1, :city, :country_id, presence: true
17
+ validates :address1, :city, :country_id, :name, presence: true
18
18
  validates :zipcode, presence: true, if: :require_zipcode?
19
19
  validates :phone, presence: true, if: :require_phone?
20
20
 
21
- validate :validate_name
22
-
23
21
  validate do
24
- if Spree::Config.use_legacy_address_state_validator
25
- begin
26
- @silence_state_deprecations = true
27
- state_validate
28
- validate_state_matches_country
29
- ensure
30
- @silence_state_deprecations = false
31
- end
32
- else
33
- self.class.state_validator_class.new(self).perform
34
- end
22
+ self.class.state_validator_class.new(self).perform
35
23
  end
36
24
 
37
- alias_attribute :first_name, :firstname
38
- alias_attribute :last_name, :lastname
39
- alias_attribute :full_name, :name
25
+ self.ignored_columns = %w(firstname lastname)
26
+ DB_ONLY_ATTRS = %w(id updated_at created_at).freeze
27
+ TAXATION_ATTRS = %w(state_id country_id zipcode).freeze
40
28
 
41
- DB_ONLY_ATTRS = %w(id updated_at created_at)
42
- TAXATION_ATTRS = %w(state_id country_id zipcode)
43
- LEGACY_NAME_ATTRS = %w(firstname lastname full_name)
44
-
45
- self.whitelisted_ransackable_attributes = %w[firstname lastname]
29
+ self.whitelisted_ransackable_attributes = %w[name]
46
30
 
47
31
  scope :with_values, ->(attributes) do
48
32
  where(value_attributes(attributes))
49
33
  end
50
34
 
51
- Spree::Deprecation.deprecate_methods(
52
- Spree::Address,
53
- LEGACY_NAME_ATTRS.product([:name]).to_h
54
- )
55
-
56
35
  # @return [Address] an address with default attributes
57
36
  def self.build_default(*args, &block)
58
37
  where(country: Spree::Country.default).build(*args, &block)
@@ -84,17 +63,7 @@ module Spree
84
63
  # @return [Hash] hash of attributes contributing to value equality with optional merge
85
64
  def self.value_attributes(base_attributes, merge_attributes = {})
86
65
  base = base_attributes.stringify_keys.merge(merge_attributes.stringify_keys)
87
-
88
- name_from_attributes = Spree::Address::Name.from_attributes(base)
89
- if base['firstname'].presence || base['first_name'].presence
90
- base['firstname'] = name_from_attributes.first_name
91
- end
92
- if base['lastname'].presence || base['last_name'].presence
93
- base['lastname'] = name_from_attributes.last_name
94
- end
95
- excluded_attributes = DB_ONLY_ATTRS + %w(first_name last_name)
96
-
97
- base.except(*excluded_attributes)
66
+ base.except(*DB_ONLY_ATTRS)
98
67
  end
99
68
 
100
69
  # @return [Hash] hash of attributes contributing to value equality
@@ -123,31 +92,6 @@ module Spree
123
92
  value_attributes == other_address.value_attributes
124
93
  end
125
94
 
126
- # @deprecated Do not use this. Use Address.== instead.
127
- def same_as?(other_address)
128
- Spree::Deprecation.warn("Address#same_as? is deprecated. It's equivalent to Address.==", caller)
129
- self == other_address
130
- end
131
-
132
- # @deprecated Do not use this. Use Address.== instead.
133
- def same_as(other_address)
134
- Spree::Deprecation.warn("Address#same_as is deprecated. It's equivalent to Address.==", caller)
135
- self == other_address
136
- end
137
-
138
- # @deprecated Do not use this
139
- def empty?
140
- Spree::Deprecation.warn("Address#empty? is deprecated.", caller)
141
- attributes.except('id', 'created_at', 'updated_at', 'country_id').all? { |_, value| value.nil? }
142
- end
143
-
144
- # This exists because the default Object#blank?, checks empty? if it is
145
- # defined, and we have defined empty.
146
- # This should be removed once empty? is removed
147
- def blank?
148
- false
149
- end
150
-
151
95
  # @return [Hash] an ActiveMerchant compatible address hash
152
96
  def active_merchant_hash
153
97
  {
@@ -192,104 +136,5 @@ module Spree
192
136
  def country_iso
193
137
  country && country.iso
194
138
  end
195
-
196
- # @return [String] the full name on this address
197
- def name
198
- Spree::Address::Name.new(
199
- read_attribute(:firstname),
200
- read_attribute(:lastname)
201
- ).value
202
- end
203
-
204
- def name=(value)
205
- return if value.nil?
206
-
207
- name_from_value = Spree::Address::Name.new(value)
208
- write_attribute(:firstname, name_from_value.first_name)
209
- write_attribute(:lastname, name_from_value.last_name)
210
- end
211
-
212
- def as_json(options = {})
213
- if Spree::Config.use_combined_first_and_last_name_in_address
214
- super(options.merge(except: LEGACY_NAME_ATTRS)).tap do |hash|
215
- hash['name'] = name
216
- end
217
- else
218
- super
219
- end
220
- end
221
-
222
- private
223
-
224
- def validate_name
225
- return if name.present?
226
-
227
- name_attribute = if Spree::Config.use_combined_first_and_last_name_in_address
228
- :name
229
- else
230
- :firstname
231
- end
232
- errors.add(name_attribute, :blank)
233
- end
234
-
235
- def state_validate
236
- unless @silence_state_deprecations
237
- Spree::Deprecation.warn \
238
- "#{self.class}#state_validate private method has been deprecated" \
239
- " and will be removed in Solidus v3." \
240
- " Check https://github.com/solidusio/solidus/pull/3129 for more details.",
241
- caller
242
- end
243
-
244
- # Skip state validation without country (also required)
245
- # or when disabled by preference
246
- return if country.blank? || !Spree::Config[:address_requires_state]
247
- return unless country.states_required
248
-
249
- # ensure associated state belongs to country
250
- if state.present?
251
- if state.country == country
252
- self.state_name = nil # not required as we have a valid state and country combo
253
- elsif state_name.present?
254
- self.state = nil
255
- else
256
- errors.add(:state, :invalid)
257
- end
258
- end
259
-
260
- # ensure state_name belongs to country without states, or that it matches a predefined state name/abbr
261
- if state_name.present?
262
- if country.states.present?
263
- states = country.states.with_name_or_abbr(state_name)
264
-
265
- if states.size == 1
266
- self.state = states.first
267
- self.state_name = nil
268
- else
269
- errors.add(:state, :invalid)
270
- end
271
- end
272
- end
273
-
274
- # ensure at least one state field is populated
275
- errors.add :state, :blank if state.blank? && state_name.blank?
276
- end
277
-
278
- def validate_state_matches_country
279
- unless @silence_state_deprecations
280
- Spree::Deprecation.warn \
281
- "#{self.class}#validate_state_matches_country private method has been deprecated" \
282
- " and will be removed in Solidus v3." \
283
- " Check https://github.com/solidusio/solidus/pull/3129 for more details.",
284
- caller
285
- end
286
-
287
- return unless country
288
-
289
- self.state = nil if country.states.empty?
290
- if state && state.country != country
291
- errors.add(:state, :does_not_match_country)
292
- end
293
- end
294
139
  end
295
140
  end