solidus_core 4.6.1 → 4.6.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ab07c75d9886b9eda75453847a2a2ec936e5aabd8bff99854a10381c4bd1dc0
4
- data.tar.gz: 58e45a9450049e9efbd8c768875a42eeabcf8529f3c23b2fb087ceaa4bd95099
3
+ metadata.gz: 03c5f9ed344221d9efde0c16e7d40604521c067f36abbf3e09b050fbc9efd3de
4
+ data.tar.gz: 920e1ac4c8266d2110c1eed180d5ffe32e8d16bab3a92ff02eab5446ecba6a2c
5
5
  SHA512:
6
- metadata.gz: 41b675b7a0df269e5ff38496b42eac3b22379192961da29717ed9a8f72b922d478d530cdbc457e6620badb5d9ccc4c006264be968c796a6495774322eabd905e
7
- data.tar.gz: ad1547dd2d1f7f6dcb024200910f59ba1d7f48845b9ae90feccbe1da1dff2da9c215d8a811ad7bd24bfc40b4bbc2be917388917d96285bf64cf67629b81079dc
6
+ metadata.gz: 3f81fd0110e433d54dc81e4f73f9f3c0e3dfc37a81c30a443ea2e9c72d0e9882362e917f121b917bfac36300cd2aae7495eec86b40c624873c4cfc5d070d6bf8
7
+ data.tar.gz: 3cedf567b53ad2a9ddee3b4da7f863787092c9d72daccc7fbd02fa4244d9447a1a8a5e3a84c9eeec080b759e57656c8a56dd3ae173f982283cb531169e715aed
@@ -5,21 +5,25 @@ module Spree
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
- after_update :enqueue_state_change_tracking, if: :saved_change_to_state?
8
+ after_update :enqueue_state_change_tracking, if: :track_state_change?
9
9
  end
10
10
 
11
11
  private
12
12
 
13
+ def track_state_change?
14
+ saved_change_to_state?
15
+ end
16
+
13
17
  # Enqueue background job to track state changes asynchronously
14
18
  def enqueue_state_change_tracking
15
19
  previous_state, current_state = saved_changes['state']
16
20
 
17
21
  # Enqueue the job to track this state change
18
- StateChangeTrackingJob.perform_later(
19
- self,
20
- previous_state,
21
- current_state,
22
- Time.current
22
+ Spree::Config.state_change_tracking_class.call(
23
+ stateful: self,
24
+ previous_state:,
25
+ current_state:,
26
+ transition_timestamp: Time.current
23
27
  )
24
28
  end
25
29
  end
@@ -83,7 +83,7 @@ module Spree
83
83
  when String
84
84
  separator = I18n.t('number.currency.format.separator')
85
85
  number = amount.delete("^0-9-#{separator}\.").tr(separator, '.')
86
- number.to_d if number.present?
86
+ number.presence&.to_d
87
87
  end || amount
88
88
  end
89
89
 
@@ -63,18 +63,18 @@ module Spree
63
63
  can :create, ReturnAuthorization do |return_authorization|
64
64
  return_authorization.order.user == user
65
65
  end
66
- can [:read, :update], CreditCard, user_id: user.id
66
+ can [:read, :update], CreditCard, user_id: user.id if user.persisted?
67
67
  can :read, Product
68
68
  can :read, ProductProperty
69
69
  can :read, Property
70
70
  can :create, Spree.user_class
71
- can [:show, :update, :update_email], Spree.user_class, id: user.id
71
+ can [:show, :update, :update_email], Spree.user_class, id: user.id if user.persisted?
72
72
  can :read, State
73
73
  can :read, StockItem, stock_location: { active: true }
74
74
  can :read, StockLocation, active: true
75
75
  can :read, Taxon
76
76
  can :read, Taxonomy
77
- can [:save_in_address_book, :remove_from_address_book], Spree.user_class, id: user.id
77
+ can [:save_in_address_book, :remove_from_address_book], Spree.user_class, id: user.id if user.persisted?
78
78
  can [:read, :view_out_of_stock], Variant
79
79
  can :read, Zone
80
80
  end
@@ -147,6 +147,11 @@ module Spree
147
147
  super || Spree::TaxCategory.find_by(is_default: true)
148
148
  end
149
149
 
150
+ # @return [Integer] tax category id for this product, or the default tax category id
151
+ def tax_category_id
152
+ super || tax_category&.id
153
+ end
154
+
150
155
  # Ensures option_types and product_option_types exist for keys in
151
156
  # option_values_hash.
152
157
  #
@@ -177,16 +177,16 @@ module Spree
177
177
  exchange_requested? || sibling_intended_for_exchange('unexchanged')
178
178
  end
179
179
 
180
+ def currency
181
+ return_authorization.try(:currency) || Spree::Config[:currency]
182
+ end
183
+
180
184
  private
181
185
 
182
186
  def persist_acceptance_status_errors
183
187
  update(acceptance_status_errors: validator.errors)
184
188
  end
185
189
 
186
- def currency
187
- return_authorization.try(:currency) || Spree::Config[:currency]
188
- end
189
-
190
190
  def process_inventory_unit!
191
191
  inventory_unit.return!
192
192
 
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ # Configurable class to enqueue state change tracking jobs
5
+ # Configure your custom logic by setting Spree::Config.state_change_tracking_class
6
+ # @example Spree::Config.state_change_tracking_class = MyCustomTracker
7
+ class StateChangeTracker
8
+ # @param stateful [Object] The stateful object to track changes for
9
+ # @param previous_state [String] The previous state of the order
10
+ # @param current_state [String] The current state of the order
11
+ # @param transition_timestamp [Time] When the state transition occurred
12
+ # @param stateful_name [String] The element name of the state transition being
13
+ # tracked. It defaults to the `stateful` model element name.
14
+ def self.call(
15
+ stateful:,
16
+ previous_state:,
17
+ current_state:,
18
+ transition_timestamp:,
19
+ stateful_name: stateful.class.model_name.element
20
+ )
21
+ # Enqueue a background job to track this state change
22
+ StateChangeTrackingJob.perform_later(
23
+ stateful,
24
+ previous_state,
25
+ current_state,
26
+ transition_timestamp,
27
+ stateful_name
28
+ )
29
+ end
30
+ end
31
+ end
@@ -3,6 +3,7 @@
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
5
  <meta name="viewport" content="width=device-width">
6
+ <%# The Ink CSS below is MIT licensed; see ink.license.txt in this directory. %>
6
7
  <style>
7
8
  /**********************************************
8
9
  * Ink v1.0.5 - Copyright 2013 ZURB Inc *
@@ -0,0 +1,28 @@
1
+ The mailer layout in this directory (base_mailer.html.erb) inlines the
2
+ CSS of Ink v1.0.5, ZURB's responsive email framework, from
3
+ https://github.com/foundation/foundation-emails (formerly zurb/ink).
4
+
5
+ --------------------------------------------------------------------------------
6
+
7
+ Copyright (c) 2013 ZURB, inc.
8
+
9
+ MIT License
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining
12
+ a copy of this software and associated documentation files (the
13
+ "Software"), to deal in the Software without restriction, including
14
+ without limitation the rights to use, copy, modify, merge, publish,
15
+ distribute, sublicense, and/or sell copies of the Software, and to
16
+ permit persons to whom the Software is furnished to do so, subject to
17
+ the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be
20
+ included in all copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -7,7 +7,7 @@ class AddShippingCategoryForeignKeys < ActiveRecord::Migration[7.0]
7
7
  # Uncomment the following code to remove orphaned records if the following code fails
8
8
  #
9
9
  # say_with_time "Removing orphaned products (no corresponding shipping category)" do
10
- # Spree::Product.left_joins(:shipping_category).where(spree_shipping_category: { id: nil }).delete_all
10
+ # Spree::Product.left_joins(:shipping_category).where(spree_shipping_categories: { id: nil }).delete_all
11
11
  # end
12
12
  begin
13
13
  add_foreign_key :spree_products, :spree_shipping_categories, column: :shipping_category_id, null: false
@@ -27,7 +27,7 @@ class AddShippingCategoryForeignKeys < ActiveRecord::Migration[7.0]
27
27
  # Uncomment the following code to remove orphaned records if the following code fails
28
28
  #
29
29
  # say_with_time "Removing orphaned shipping method categories (no corresponding shipping category)" do
30
- # Spree::ShippingMethodCategory.left_joins(:shipping_category).where(spree_shipping_category: { id: nil }).delete_all
30
+ # Spree::ShippingMethodCategory.left_joins(:shipping_category).where(spree_shipping_categories: { id: nil }).delete_all
31
31
  # end
32
32
  begin
33
33
  add_foreign_key :spree_shipping_method_categories, :spree_shipping_methods, column: :shipping_method_id, null: false
@@ -47,7 +47,7 @@ class AddShippingCategoryForeignKeys < ActiveRecord::Migration[7.0]
47
47
  # Uncomment the following code to remove orphaned records if the following code fails
48
48
  #
49
49
  # say_with_time "Removing orphaned shipping method categories (no corresponding shipping method)" do
50
- # Spree::ShippingMethodCategory.left_joins(:shipping_method).where(spree_shipping_method: { id: nil }).delete_all
50
+ # Spree::ShippingMethodCategory.left_joins(:shipping_method).where(spree_shipping_methods: { id: nil }).delete_all
51
51
  # end
52
52
  begin
53
53
  add_foreign_key :spree_shipping_method_categories, :spree_shipping_categories, column: :shipping_category_id, null: false
@@ -4,7 +4,9 @@ begin
4
4
  user_class.classify.constantize
5
5
  rescue NameError
6
6
  say_status :error, "Can't find an existing user class named #{user_class.classify}, plese set up one before using this authentication option.", :red
7
+ # rubocop:disable Rails/Exit
7
8
  abort
9
+ # rubocop:enable Rails/Exit
8
10
  end
9
11
 
10
12
  generate "spree:custom_user #{user_class.shellescape}"
@@ -549,6 +549,13 @@ module Spree
549
549
  product: '680x680>',
550
550
  large: '1200x1200>' }
551
551
 
552
+ # Allows to provide your own class for tracking state changes of stateful models
553
+ #
554
+ # @!attribute [rw] state_change_tracking_class
555
+ # @return [Class] a class with the same public interfaces as
556
+ # Spree::StateChangeTracker.
557
+ class_name_attribute :state_change_tracking_class, default: "Spree::StateChangeTracker"
558
+
552
559
  # Allows providing your own class for prioritizing store credit application
553
560
  # to an order.
554
561
  #
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spree
4
- VERSION = "4.6.1"
4
+ VERSION = "4.6.3"
5
5
 
6
6
  def self.solidus_version = VERSION
7
7
 
@@ -73,7 +73,7 @@ module Spree
73
73
 
74
74
  @@option_type_attributes = [:name, :presentation, option_values_attributes: option_value_attributes]
75
75
 
76
- @@payment_attributes = [:amount, :payment_method_id, :payment_method, customer_metadata: {}]
76
+ @@payment_attributes = [:payment_method_id, :payment_method, customer_metadata: {}]
77
77
 
78
78
  @@product_properties_attributes = [:property_name, :value, :position]
79
79
 
@@ -165,6 +165,7 @@ module Spree
165
165
 
166
166
  @@checkout_payment_attributes = [
167
167
  payments_attributes: payment_attributes + [
168
+ :amount,
168
169
  source_attributes:
169
170
  ]
170
171
  ]
@@ -10,7 +10,7 @@ module Spree
10
10
  def up_to(state, user: nil)
11
11
  # Need to create a valid zone too...
12
12
  @zone = ::FactoryBot.create(:zone)
13
- @country = ::FactoryBot.create(:country)
13
+ @country = Spree::Country.find_by(iso: "US") || ::FactoryBot.create(:country)
14
14
  @state = ::FactoryBot.create(:state, country: @country)
15
15
 
16
16
  @zone.members << Spree::ZoneMember.create(zoneable: @country)
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.shared_examples "tracking state changes" do
4
+ context "with track_state_change? true" do
5
+ before do
6
+ expect(stateful).to receive(:track_state_change?).and_return(true)
7
+ end
8
+
9
+ it "enqueues state change tracking job" do
10
+ expect { stateful.update!(state:) }
11
+ .to enqueue_job(Spree::StateChangeTrackingJob)
12
+ end
13
+ end
14
+
15
+ context "with track_state_change? false" do
16
+ before do
17
+ expect(stateful).to receive(:track_state_change?).and_return(false)
18
+ end
19
+
20
+ it "does not enqueue state change tracking job" do
21
+ expect { stateful.update!(state:) }
22
+ .not_to enqueue_job(Spree::StateChangeTrackingJob)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ This license covers the vendored jQuery.payment v1.3.2 (jquery.payment.js
2
+ in this directory), from https://github.com/stripe-archive/jquery.payment.
3
+
4
+ --------------------------------------------------------------------------------
5
+
6
+ Copyright (c) 2014 Stripe
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining
9
+ a copy of this software and associated documentation files (the
10
+ "Software"), to deal in the Software without restriction, including
11
+ without limitation the rights to use, copy, modify, merge, publish,
12
+ distribute, sublicense, and/or sell copies of the Software, and to
13
+ permit persons to whom the Software is furnished to do so, subject to
14
+ the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be
17
+ included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,12 @@
1
+ This license covers the vendored jsUri v1.1.1 (jsuri.js in this
2
+ directory), from https://github.com/derek-watson/jsUri.
3
+
4
+ --------------------------------------------------------------------------------
5
+
6
+ Copyright (c) 2014, Derek Watson
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.1
4
+ version: 4.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
@@ -684,6 +684,7 @@ files:
684
684
  - app/models/spree/simple_order_contents.rb
685
685
  - app/models/spree/state.rb
686
686
  - app/models/spree/state_change.rb
687
+ - app/models/spree/state_change_tracker.rb
687
688
  - app/models/spree/stock/allocator/base.rb
688
689
  - app/models/spree/stock/allocator/on_hand_first.rb
689
690
  - app/models/spree/stock/availability.rb
@@ -767,6 +768,7 @@ files:
767
768
  - app/subscribers/spree/order_mailer_subscriber.rb
768
769
  - app/subscribers/spree/reimbursement_mailer_subscriber.rb
769
770
  - app/views/layouts/spree/base_mailer.html.erb
771
+ - app/views/layouts/spree/ink.license.txt
770
772
  - app/views/spree/carton_mailer/shipped_email.html.erb
771
773
  - app/views/spree/carton_mailer/shipped_email.text.erb
772
774
  - app/views/spree/order_mailer/cancel_email.html.erb
@@ -1056,6 +1058,7 @@ files:
1056
1058
  - lib/spree/testing_support/shared_examples/calculator.rb
1057
1059
  - lib/spree/testing_support/shared_examples/gallery.rb
1058
1060
  - lib/spree/testing_support/shared_examples/order_factory.rb
1061
+ - lib/spree/testing_support/shared_examples/state_change_tracking.rb
1059
1062
  - lib/spree/testing_support/shared_examples/working_factory.rb
1060
1063
  - lib/spree/testing_support/silence_deprecations.rb
1061
1064
  - lib/spree/testing_support/translations.rb
@@ -1068,7 +1071,9 @@ files:
1068
1071
  - lib/tasks/solidus/delete_prices_with_nil_amount.rake
1069
1072
  - solidus_core.gemspec
1070
1073
  - vendor/assets/javascripts/jquery.payment.js
1074
+ - vendor/assets/javascripts/jquery.payment.license.txt
1071
1075
  - vendor/assets/javascripts/jsuri.js
1076
+ - vendor/assets/javascripts/jsuri.license.txt
1072
1077
  - vendor/assets/stylesheets/normalize.css
1073
1078
  homepage: http://solidus.io
1074
1079
  licenses:
@@ -1112,7 +1117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1112
1117
  - !ruby/object:Gem::Version
1113
1118
  version: 1.8.23
1114
1119
  requirements: []
1115
- rubygems_version: 3.6.9
1120
+ rubygems_version: 4.0.10
1116
1121
  specification_version: 4
1117
1122
  summary: Essential models, mailers, and classes for the Solidus e-commerce project.
1118
1123
  test_files: []