solidus_core 3.0.8 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/spree/base_helper.rb +1 -1
  3. data/app/helpers/spree/products_helper.rb +1 -1
  4. data/app/models/concerns/spree/active_storage_adapter/attachment.rb +2 -4
  5. data/app/models/concerns/spree/default_price.rb +63 -10
  6. data/app/models/concerns/spree/user_methods.rb +1 -20
  7. data/app/models/spree/adjustment.rb +6 -5
  8. data/app/models/spree/customer_return.rb +3 -2
  9. data/app/models/spree/image/active_storage_attachment.rb +2 -7
  10. data/app/models/spree/image/paperclip_attachment.rb +2 -2
  11. data/app/models/spree/line_item.rb +2 -2
  12. data/app/models/spree/log_entry.rb +1 -74
  13. data/app/models/spree/order.rb +10 -5
  14. data/app/models/spree/order_shipping.rb +9 -6
  15. data/app/models/spree/price.rb +2 -2
  16. data/app/models/spree/product/scopes.rb +5 -5
  17. data/app/models/spree/product.rb +12 -1
  18. data/app/models/spree/promotion/rules/item_total.rb +50 -6
  19. data/app/models/spree/promotion.rb +2 -2
  20. data/app/models/spree/promotion_code.rb +3 -3
  21. data/app/models/spree/refund.rb +0 -8
  22. data/app/models/spree/shipping_rate_tax.rb +1 -1
  23. data/app/models/spree/stock/availability.rb +11 -3
  24. data/app/models/spree/stock/simple_coordinator.rb +0 -10
  25. data/app/models/spree/stock_location.rb +1 -1
  26. data/app/models/spree/store_credit.rb +6 -9
  27. data/app/models/spree/tax_calculator/shipping_rate.rb +1 -1
  28. data/app/models/spree/taxon/active_storage_attachment.rb +2 -2
  29. data/app/models/spree/taxon/paperclip_attachment.rb +3 -3
  30. data/app/models/spree/variant/price_selector.rb +16 -3
  31. data/app/models/spree/variant.rb +26 -16
  32. data/config/locales/en.yml +2 -249
  33. data/db/migrate/20210312061050_change_column_null_on_prices.rb +7 -0
  34. data/lib/generators/solidus/install/install_generator.rb +2 -3
  35. data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +3 -1
  36. data/lib/generators/solidus/update/templates/config/initializers/new_solidus_defaults.rb.tt +30 -0
  37. data/lib/generators/solidus/update/update_generator.rb +112 -0
  38. data/lib/generators/spree/dummy/templates/rails/application.rb.tt +0 -1
  39. data/lib/generators/spree/dummy/templates/rails/database.yml +78 -35
  40. data/lib/spree/app_configuration.rb +64 -19
  41. data/lib/spree/core/engine.rb +7 -22
  42. data/lib/spree/core/product_filters.rb +1 -1
  43. data/lib/spree/core/search/base.rb +1 -1
  44. data/lib/spree/core/state_machines/order.rb +1 -1
  45. data/lib/spree/core/validators/email.rb +1 -1
  46. data/lib/spree/core/version.rb +5 -1
  47. data/lib/spree/core/versioned_value.rb +75 -0
  48. data/lib/spree/core.rb +17 -0
  49. data/lib/spree/permitted_attributes.rb +1 -1
  50. data/lib/spree/preferences/configuration.rb +62 -0
  51. data/lib/spree/preferences/preferable.rb +8 -0
  52. data/lib/spree/preferences/preferable_class_methods.rb +5 -3
  53. data/lib/spree/preferences/preference_differentiator.rb +28 -0
  54. data/lib/spree/testing_support/blacklist_urls.rb +1 -1
  55. data/lib/spree/testing_support/dummy_app/database.yml +42 -22
  56. data/lib/spree/testing_support/dummy_app.rb +33 -19
  57. data/lib/spree/testing_support/factories/user_factory.rb +0 -6
  58. data/lib/tasks/solidus/delete_prices_with_nil_amount.rake +8 -0
  59. data/solidus_core.gemspec +0 -1
  60. metadata +9 -26
  61. data/app/models/spree/tax/shipping_rate_taxer.rb +0 -24
  62. data/lib/tasks/solidus/check_orders_with_invalid_email.rake +0 -18
  63. data/lib/tasks/upgrade.rake +0 -15
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'spree/core/versioned_value'
3
4
  require 'spree/preferences/preferable'
4
5
 
5
6
  module Spree::Preferences
@@ -29,6 +30,44 @@ module Spree::Preferences
29
30
  class Configuration
30
31
  include Spree::Preferences::Preferable
31
32
 
33
+ # @!attribute [r] loaded_defaults
34
+ # @return [String]
35
+ # Some configuration defaults can be added or changed when a new Solidus
36
+ # version is released. Setting this to an older Solidus version allows keeping
37
+ # backward compatibility until the application code is updated to the new
38
+ # defaults. Set via {#load_defaults}
39
+ attr_reader :loaded_defaults
40
+
41
+ attr_reader :load_defaults_called
42
+
43
+ def initialize
44
+ @loaded_defaults = Spree.solidus_version
45
+ @load_defaults_called = false
46
+ end
47
+
48
+ # @param [String] Solidus version from which take defaults when not
49
+ # overriden.
50
+ # @see #load_defaults
51
+ def load_defaults(version)
52
+ @loaded_defaults = version
53
+ @load_defaults_called = true
54
+ reset
55
+ end
56
+
57
+ def check_load_defaults_called(instance_constant_name = nil)
58
+ return if load_defaults_called || !Spree::Core.has_install_generator_been_run?
59
+
60
+ target_name = instance_constant_name || "#{self.class.name}.new"
61
+ Spree::Deprecation.warn <<~MSG
62
+ It's recommended that you explicitly load the default configuration for
63
+ your current Solidus version. You can do it by adding the following call
64
+ to your Solidus initializer within the #{target_name} block:
65
+
66
+ config.load_defaults('#{Spree.solidus_version}')
67
+
68
+ MSG
69
+ end
70
+
32
71
  # @yield [config] Yields this configuration object to a block
33
72
  def configure
34
73
  yield(self)
@@ -79,6 +118,23 @@ module Spree::Preferences
79
118
  end
80
119
  end
81
120
 
121
+ # Generates a different preference default depending on {#version_defaults}
122
+ #
123
+ # This method is meant to be used in the `default:` keyword argument for
124
+ # {.preference}. For instance, in the example, `foo`'s default was `true`
125
+ # until version 3.0.0.alpha, when it became `false`:
126
+ #
127
+ # @example
128
+ # preference :foo, :boolean, default: by_version(true, "3.0.0.alpha" => false)
129
+ #
130
+ # @see #loaded_defaults
131
+ # @see Spree::Core::VersionedValue
132
+ def self.by_version(*args)
133
+ proc do |loaded_defaults|
134
+ Spree::Core::VersionedValue.new(*args).call(loaded_defaults)
135
+ end
136
+ end
137
+
82
138
  def self.preference(name, type, options = {})
83
139
  super
84
140
  alias_method name.to_s, "preferred_#{name}"
@@ -103,5 +159,11 @@ module Spree::Preferences
103
159
  class_name
104
160
  end
105
161
  end
162
+
163
+ private
164
+
165
+ def context_for_default
166
+ [loaded_defaults]
167
+ end
106
168
  end
107
169
  end
@@ -11,6 +11,10 @@ module Spree
11
11
  # A class including Preferable must implement #preferences which should return
12
12
  # an object responding to .fetch(key), []=(key, val), and .delete(key).
13
13
  #
14
+ # It may also define a `#context_for_default` method. It should return an
15
+ # array with the arguments to be provided to a proc used as the `default:`
16
+ # keyword for a preference.
17
+ #
14
18
  # The generated writer method performs typecasting before assignment into the
15
19
  # preferences object.
16
20
  #
@@ -176,6 +180,10 @@ module Spree
176
180
  value
177
181
  end
178
182
  end
183
+
184
+ def context_for_default
185
+ [].freeze
186
+ end
179
187
  end
180
188
  end
181
189
  end
@@ -27,7 +27,7 @@ module Spree::Preferences
27
27
  end
28
28
 
29
29
  default = options[:default]
30
- default = ->{ options[:default] } unless default.is_a?(Proc)
30
+ default = proc { options[:default] } unless default.is_a?(Proc)
31
31
 
32
32
  # The defined preferences on a class are all those defined directly on
33
33
  # that class as well as those defined on ancestors.
@@ -44,7 +44,7 @@ module Spree::Preferences
44
44
  # is a pending preference before going to default
45
45
  define_method preference_getter_method(name) do
46
46
  value = preferences.fetch(name) do
47
- default.call
47
+ default.call(*context_for_default)
48
48
  end
49
49
  value = preference_encryptor.decrypt(value) if preference_encryptor.present?
50
50
  value
@@ -60,7 +60,9 @@ module Spree::Preferences
60
60
  preferences_will_change! if respond_to?(:preferences_will_change!)
61
61
  end
62
62
 
63
- define_method preference_default_getter_method(name), &default
63
+ define_method preference_default_getter_method(name) do
64
+ default.call(*context_for_default)
65
+ end
64
66
 
65
67
  define_method preference_type_getter_method(name) do
66
68
  type
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module Preferences
5
+ class PreferenceDifferentiator
6
+ attr_reader :config_class
7
+
8
+ def initialize(config_class)
9
+ @config_class = config_class
10
+ end
11
+
12
+ def call(from:, to:)
13
+ preferences_from = config_class.new.load_defaults(from)
14
+ preferences_to = config_class.new.load_defaults(to)
15
+ preferences_from.reduce({}) do |changes, (pref_key, value_from)|
16
+ value_to = preferences_to[pref_key]
17
+ if value_from == value_to
18
+ changes
19
+ else
20
+ changes.merge(
21
+ pref_key => { from: value_from, to: value_to }
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -5,7 +5,7 @@ module Spree
5
5
  module BlacklistUrls
6
6
  def setup_url_blacklist(browser)
7
7
  if browser.respond_to?(:url_blacklist)
8
- browser.url_blacklist = ['https://fonts.googleapis.com']
8
+ browser.url_blacklist = ['http://fonts.googleapis.com']
9
9
  end
10
10
  end
11
11
  end
@@ -1,34 +1,54 @@
1
- <%
2
- database_prefix = ENV['LIB_NAME'].presence || "solidus"
3
- %>
4
- <% case ENV['DB']
1
+ <% db = case ENV['DB']
2
+ when 'mysql'
3
+ 'mysql'
4
+ when 'postgres', 'postgresql'
5
+ 'postgres'
6
+ when 'sqlite', '', nil
7
+ 'sqlite'
8
+ else
9
+ raise "Invalid DB specified: #{ENV['DB']}"
10
+ end %>
11
+ <% db_host = case db
12
+ when 'mysql'
13
+ ENV['DB_MYSQL_HOST'] || ENV['DB_HOST']
14
+ when 'postgres'
15
+ ENV['DB_POSTGRES_HOST'] || ENV['DB_HOST']
16
+ else
17
+ ENV['DB_HOST']
18
+ end %>
19
+ <% db_prefix = ENV['LIB_NAME'].presence || "solidus" %>
20
+ <% db_username = ENV['DB_USERNAME'] %>
21
+ <% db_password = ENV['DB_PASSWORD'] %>
22
+ <% case db
5
23
  when 'mysql' %>
6
24
  test:
7
25
  adapter: mysql2
8
- <% if ENV['CI'] %>
9
- username: root
10
- password:
26
+ database: <%= db_prefix %>_test
27
+ <% unless db_username.blank? %>
28
+ username: <%= db_username %>
11
29
  <% end %>
12
- database: <%= database_prefix %>_test
13
- encoding: utf8
14
- <% unless ENV['DB_HOST'].blank? %>
15
- host: <%= ENV['DB_HOST'] %>
30
+ <% unless db_password.blank? %>
31
+ password: <%= db_password %>
32
+ <% end %>
33
+ <% unless db_host.blank? %>
34
+ host: <%= db_host %>
16
35
  <% end %>
17
- <% when 'postgres', 'postgresql' %>
18
- <% db_host = ENV['DB_HOST'] %>
36
+ encoding: utf8
37
+ <% when 'postgres' %>
19
38
  test:
20
39
  adapter: postgresql
21
- database: <%= database_prefix %>_test
22
- username: postgres
23
- min_messages: warning
24
- <% unless db_host.blank? %>
40
+ database: <%= db_prefix %>_test
41
+ username: <%= db_username.presence || "postgres" %>
42
+ <% unless db_password.blank? %>
43
+ password: <%= db_password %>
44
+ <% end %>
45
+ <% unless db_host.blank? %>
25
46
  host: <%= db_host %>
26
- <% end %>
27
- <% when 'sqlite', '', nil %>
47
+ <% end %>
48
+ min_messages: warning
49
+ <% when 'sqlite' %>
28
50
  test:
29
51
  adapter: sqlite3
30
- database: db/<%= database_prefix %>_test.sqlite3
52
+ database: db/<%= db_prefix %>_test.sqlite3
31
53
  timeout: 10000
32
- <% else %>
33
- <% raise "Invalid DB specified: #{ENV['DB']}" %>
34
54
  <% end %>
@@ -46,39 +46,56 @@ module DummyApp
46
46
  end
47
47
 
48
48
  class Application < ::Rails::Application
49
- config.has_many_inverse = true
50
- config.eager_load = false
49
+ config.load_defaults("#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}")
50
+ # Make the test environment more production-like:
51
51
  config.cache_classes = true
52
- config.cache_store = :memory_store
53
- config.serve_static_assets = true
54
- config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
55
- config.whiny_nils = true
56
- config.consider_all_requests_local = true
57
52
  config.action_controller.allow_forgery_protection = false
58
53
  config.action_controller.default_protect_from_forgery = false
54
+ config.action_mailer.perform_caching = false
55
+ config.i18n.fallbacks = true
56
+
57
+ # In the test environment, we use the `caching: true` RSpec metadata to
58
+ # enable caching on select specs. See
59
+ # core/lib/spree/testing_support/caching.rb. See also
60
+ # https://github.com/solidusio/solidus/issues/4110
59
61
  config.action_controller.perform_caching = false
62
+
63
+ # Make debugging easier:
64
+ config.consider_all_requests_local = true
60
65
  config.action_dispatch.show_exceptions = false
61
66
  config.active_support.deprecation = :stderr
67
+ config.log_level = :debug
68
+
69
+ # Improve test suite performance:
70
+ config.eager_load = false
71
+ config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
72
+ config.cache_store = :memory_store
73
+
74
+ # We don't use a web server, so we let Rails serve assets.
75
+ config.public_file_server.enabled = true
76
+
77
+ # We don't want to send email in the test environment.
62
78
  config.action_mailer.delivery_method = :test
63
- config.active_support.deprecation = :stderr
79
+
80
+ # No need to use credentials file in a test environment.
64
81
  config.secret_key_base = 'SECRET_TOKEN'
65
82
 
66
- config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob" if RAILS_6_OR_ABOVE
83
+ # Set the preview path within the dummy app:
67
84
  config.action_mailer.preview_path = File.expand_path('dummy_app/mailer_previews', __dir__)
68
- config.active_record.sqlite3.represent_boolean_as_integer = true unless RAILS_6_OR_ABOVE
69
85
 
70
- config.storage_path = Rails.root.join('tmp', 'storage')
86
+ config.active_record.sqlite3.represent_boolean_as_integer = true unless RAILS_6_OR_ABOVE
87
+ config.active_record.dump_schema_after_migration = false
71
88
 
89
+ # Configure active storage to use storage within tmp folder
72
90
  unless ENV['DISABLE_ACTIVE_STORAGE']
73
91
  initializer 'solidus.active_storage' do
74
92
  config.active_storage.service_configurations = {
75
93
  test: {
76
94
  service: 'Disk',
77
- root: config.storage_path
95
+ root: Rails.root.join('tmp', 'storage')
78
96
  }
79
97
  }
80
98
  config.active_storage.service = :test
81
- config.active_storage.variant_processor = ENV.fetch('ACTIVE_STORAGE_VARIANT_PROCESSOR', :mini_magick).to_sym
82
99
  end
83
100
  end
84
101
 
@@ -96,12 +113,8 @@ module DummyApp
96
113
  config.paths['db/migrate'] = migration_dirs
97
114
  ActiveRecord::Migrator.migrations_paths = migration_dirs
98
115
 
99
- config.action_controller.include_all_helpers = false
100
-
101
- if config.respond_to?(:assets)
102
- config.assets.paths << File.expand_path('dummy_app/assets/javascripts', __dir__)
103
- config.assets.paths << File.expand_path('dummy_app/assets/stylesheets', __dir__)
104
- end
116
+ config.assets.paths << File.expand_path('dummy_app/assets/javascripts', __dir__)
117
+ config.assets.paths << File.expand_path('dummy_app/assets/stylesheets', __dir__)
105
118
 
106
119
  config.paths["config/database"] = File.expand_path('dummy_app/database.yml', __dir__)
107
120
  config.paths['app/views'] = File.expand_path('dummy_app/views', __dir__)
@@ -118,6 +131,7 @@ ActiveSupport.on_load(:action_controller) do
118
131
  end
119
132
 
120
133
  Spree.user_class = 'Spree::LegacyUser'
134
+ Spree.load_defaults(Spree.solidus_version)
121
135
  Spree.config do |config|
122
136
  config.mails_from = "store@example.com"
123
137
 
@@ -21,12 +21,6 @@ FactoryBot.define do
21
21
  end
22
22
  end
23
23
 
24
- trait :with_orders do
25
- after(:create) do |user, _|
26
- create(:order, user: user)
27
- end
28
- end
29
-
30
24
  factory :admin_user do
31
25
  after(:create) do |user, _|
32
26
  admin_role = Spree::Role.find_by(name: 'admin') || create(:role, name: 'admin')
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :solidus do
4
+ desc "Delete Spree::Price records which amount field is NULL"
5
+ task delete_prices_with_nil_amount: :environment do
6
+ Spree::Price.where(amount: nil).delete_all
7
+ end
8
+ end
data/solidus_core.gemspec CHANGED
@@ -40,7 +40,6 @@ Gem::Specification.new do |s|
40
40
  s.add_dependency 'mini_magick', '~> 4.10'
41
41
  s.add_dependency 'monetize', '~> 1.8'
42
42
  s.add_dependency 'kt-paperclip', '~> 6.3'
43
- s.add_dependency 'psych', ['>= 3.1.0', '< 5.0']
44
43
  s.add_dependency 'ransack', '~> 2.0'
45
44
  s.add_dependency 'state_machines-activerecord', '~> 0.6'
46
45
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.8
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-22 00:00:00.000000000 Z
11
+ date: 2021-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -344,26 +344,6 @@ dependencies:
344
344
  - - "~>"
345
345
  - !ruby/object:Gem::Version
346
346
  version: '6.3'
347
- - !ruby/object:Gem::Dependency
348
- name: psych
349
- requirement: !ruby/object:Gem::Requirement
350
- requirements:
351
- - - ">="
352
- - !ruby/object:Gem::Version
353
- version: 3.1.0
354
- - - "<"
355
- - !ruby/object:Gem::Version
356
- version: '5.0'
357
- type: :runtime
358
- prerelease: false
359
- version_requirements: !ruby/object:Gem::Requirement
360
- requirements:
361
- - - ">="
362
- - !ruby/object:Gem::Version
363
- version: 3.1.0
364
- - - "<"
365
- - !ruby/object:Gem::Version
366
- version: '5.0'
367
347
  - !ruby/object:Gem::Dependency
368
348
  name: ransack
369
349
  requirement: !ruby/object:Gem::Requirement
@@ -629,7 +609,6 @@ files:
629
609
  - app/models/spree/tax/item_tax.rb
630
610
  - app/models/spree/tax/order_adjuster.rb
631
611
  - app/models/spree/tax/order_tax.rb
632
- - app/models/spree/tax/shipping_rate_taxer.rb
633
612
  - app/models/spree/tax/tax_helpers.rb
634
613
  - app/models/spree/tax/tax_location.rb
635
614
  - app/models/spree/tax_calculator/default.rb
@@ -725,6 +704,7 @@ files:
725
704
  - db/migrate/20200530111458_add_bcc_email_to_spree_stores.rb
726
705
  - db/migrate/20201008213609_add_discontinue_on_to_spree_products.rb
727
706
  - db/migrate/20210122110141_add_name_to_spree_addresses.rb
707
+ - db/migrate/20210312061050_change_column_null_on_prices.rb
728
708
  - db/seeds.rb
729
709
  - lib/generators/solidus/install/install_generator.rb
730
710
  - lib/generators/solidus/install/templates/config/initializers/spree.rb.tt
@@ -732,6 +712,8 @@ files:
732
712
  - lib/generators/solidus/install/templates/vendor/assets/javascripts/spree/frontend/all.js
733
713
  - lib/generators/solidus/install/templates/vendor/assets/stylesheets/spree/backend/all.css
734
714
  - lib/generators/solidus/install/templates/vendor/assets/stylesheets/spree/frontend/all.css
715
+ - lib/generators/solidus/update/templates/config/initializers/new_solidus_defaults.rb.tt
716
+ - lib/generators/solidus/update/update_generator.rb
735
717
  - lib/generators/spree/custom_user/custom_user_generator.rb
736
718
  - lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt
737
719
  - lib/generators/spree/custom_user/templates/migration.rb.tt
@@ -785,6 +767,7 @@ files:
785
767
  - lib/spree/core/stock_configuration.rb
786
768
  - lib/spree/core/validators/email.rb
787
769
  - lib/spree/core/version.rb
770
+ - lib/spree/core/versioned_value.rb
788
771
  - lib/spree/deprecation.rb
789
772
  - lib/spree/encryptor.rb
790
773
  - lib/spree/event.rb
@@ -824,6 +807,7 @@ files:
824
807
  - lib/spree/preferences/persistable.rb
825
808
  - lib/spree/preferences/preferable.rb
826
809
  - lib/spree/preferences/preferable_class_methods.rb
810
+ - lib/spree/preferences/preference_differentiator.rb
827
811
  - lib/spree/preferences/scoped_store.rb
828
812
  - lib/spree/preferences/static_model_preferences.rb
829
813
  - lib/spree/preferences/statically_configurable.rb
@@ -923,8 +907,7 @@ files:
923
907
  - lib/spree/testing_support/url_helpers.rb
924
908
  - lib/spree/user_class_handle.rb
925
909
  - lib/spree_core.rb
926
- - lib/tasks/solidus/check_orders_with_invalid_email.rake
927
- - lib/tasks/upgrade.rake
910
+ - lib/tasks/solidus/delete_prices_with_nil_amount.rake
928
911
  - solidus_core.gemspec
929
912
  - vendor/assets/javascripts/jquery.payment.js
930
913
  - vendor/assets/javascripts/jsuri.js
@@ -965,7 +948,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
965
948
  - !ruby/object:Gem::Version
966
949
  version: 1.8.23
967
950
  requirements: []
968
- rubygems_version: 3.3.7
951
+ rubygems_version: 3.2.20
969
952
  signing_key:
970
953
  specification_version: 4
971
954
  summary: Essential models, mailers, and classes for the Solidus e-commerce project.
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Spree
4
- module Tax
5
- # Used to build shipping rate taxes
6
- class ShippingRateTaxer
7
- # Build shipping rate taxes for a shipping rate
8
- # Modifies the passed-in shipping rate with associated shipping rate taxes.
9
- # @param [Spree::ShippingRate] shipping_rate The shipping rate to add taxes to.
10
- # This parameter will be modified.
11
- # @return [Spree::ShippingRate] The shipping rate with associated tax objects
12
- def tax(shipping_rate)
13
- taxes = Spree::Config.shipping_rate_tax_calculator_class.new(shipping_rate.order).calculate(shipping_rate)
14
- taxes.each do |tax|
15
- shipping_rate.taxes.build(
16
- amount: tax.amount,
17
- tax_rate: tax.tax_rate
18
- )
19
- end
20
- shipping_rate
21
- end
22
- end
23
- end
24
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- namespace :solidus do
4
- desc 'Prints orders with invalid email (after fix for GHSA-qxmr-qxh6-2cc9)'
5
- task check_orders_with_invalid_email: :environment do
6
- matches = Spree::Order.find_each.reduce([]) do |matches, order|
7
- order.email.nil? || Spree::EmailValidator::EMAIL_REGEXP.match?(order.email) ? matches : matches + [order]
8
- end
9
- if matches.any?
10
- puts 'Email / ID / Number'
11
- puts(matches.map do |order|
12
- "#{order.email} / #{order.id} / #{order.number}"
13
- end.join("\n"))
14
- else
15
- puts 'NO MATCHES'
16
- end
17
- end
18
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- namespace :solidus do
4
- namespace :upgrade do
5
- task three_point_zero: [
6
- 'railties:install:migrations',
7
- 'db:migrate'
8
- ] do
9
- puts "Your Solidus install is ready for Solidus 3.0"
10
- end
11
- end
12
-
13
- desc "Upgrade to the current Solidus version"
14
- task upgrade: 'upgrade:three_point_zero'
15
- end