spree_core 5.1.0.beta → 5.1.0.beta2

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: 7c1195535152943b227b48f47f34f8a53164727cff509e72ef64a720b4dfbf36
4
- data.tar.gz: e88f4d0212bf72d2ef986faae3bd97a1793cffa2fa215a7d078f47044a1ad8f8
3
+ metadata.gz: f8150046e1776256aacec11512b848d9cbd5074d17b7aacafd7b2736cfd934c3
4
+ data.tar.gz: 8a04db5d73b2abf21a587ea66313d4fb7ff7120ed46ef9d22f38ddf1b3c5f295
5
5
  SHA512:
6
- metadata.gz: 702032f4dbd79afda63c303e4f2a957e982f6cac18f95dded6f241a920f6600b3ea5e08253780185b7e87ec4d676dd4fa7d6fa92c99e43e4cb79420afeef94ad
7
- data.tar.gz: 72a2841b3265909bcc97404cc8c504216dc65033b251010ba96acc2e666ece5c30cba4902eed857ced89598c9b411659f424a376c61230d5d71771deda6660cb
6
+ metadata.gz: 8024d8aa8b617d7be12713acf1787a7c4569dc708d74cbf34850ec6bc8fcea5630c15fdfe6efa4796c82825fc9724d637b219da887f888f909dd29d22582178f
7
+ data.tar.gz: 60db3009f9a9a30bfca2b8c6895b7777a35eaac8819ca06a112e2315e234137ee87e5fea3796335e53e8a8e5c562f22183d7d8c6c3c3b1f8e9466d76ba3bbde5
@@ -7,14 +7,6 @@ module Spree
7
7
  @shippable = String(params[:filter][:shippable]) unless params[:filter].nil?
8
8
  end
9
9
 
10
- def call
11
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
12
- Spree::Countries::Find.new.call is deprecated and will be removed in Spree 5.0.
13
- Please use Spree::Countries::Find.new.execute instead
14
- DEPRECATION
15
- execute
16
- end
17
-
18
10
  def execute
19
11
  countries = by_shippability(scope)
20
12
 
@@ -136,10 +136,7 @@ module Spree
136
136
  def pretty_time(time)
137
137
  return '' if time.blank?
138
138
 
139
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
140
- `BaseHelper#pretty_time` is deprecated and will be removed in Spree 6.0.
141
- Please add `local_time` gem to your Gemfile and use `local_time(time)` instead
142
- DEPRECATION
139
+ Spree::Deprecation.warn('BaseHelper#pretty_time is deprecated and will be removed in Spree 6.0. Please add `local_time` gem to your Gemfile and use `local_time(time)` instead')
143
140
 
144
141
  [I18n.l(time.to_date, format: :long), time.strftime('%l:%M %p %Z')].join(' ')
145
142
  end
@@ -147,10 +144,7 @@ module Spree
147
144
  def pretty_date(date)
148
145
  return '' if date.blank?
149
146
 
150
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
151
- `BaseHelper#pretty_date` is deprecated and will be removed in Spree 6.0.
152
- Please add `local_time` gem to your Gemfile and use `local_date(date)` instead
153
- DEPRECATION
147
+ Spree::Deprecation.warn('BaseHelper#pretty_date is deprecated and will be removed in Spree 6.0. Please add `local_time` gem to your Gemfile and use `local_date(date)` instead')
154
148
 
155
149
  [I18n.l(date.to_date, format: :long)].join(' ')
156
150
  end
@@ -219,19 +213,13 @@ module Spree
219
213
  # we should always try to render image of the default variant
220
214
  # same as it's done on PDP
221
215
  def default_image_for_product(product)
222
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
223
- `BaseHelper#default_image_for_product` is deprecated and will be removed in Spree 6.0.
224
- Please use `product.default_image` instead
225
- DEPRECATION
216
+ Spree::Deprecation.warn('BaseHelper#default_image_for_product is deprecated and will be removed in Spree 6.0. Please use product.default_image instead')
226
217
 
227
218
  product.default_image
228
219
  end
229
220
 
230
221
  def default_image_for_product_or_variant(product_or_variant)
231
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
232
- `BaseHelper#default_image_for_product_or_variant` is deprecated and will be removed in Spree 6.0.
233
- Please use `product_or_variant.default_image` instead
234
- DEPRECATION
222
+ Spree::Deprecation.warn('BaseHelper#default_image_for_product_or_variant is deprecated and will be removed in Spree 6.0. Please use product_or_variant.default_image instead')
235
223
 
236
224
  product_or_variant.default_image
237
225
  end
@@ -1,10 +1,11 @@
1
1
  module Spree
2
2
  module MailHelper
3
- include BaseHelper
3
+ include Spree::BaseHelper
4
+ include Spree::ImagesHelper
4
5
 
5
6
  def variant_image_url(variant)
6
- image = default_image_for_product_or_variant(variant)
7
- image ? main_app.cdn_image_url(image.url(:small)) : image_url('noimage/small.png')
7
+ image = variant.default_image
8
+ image.present? && image.attached? ? spree_image_url(image, width: 100, height: 100) : image_url('noimage/small.png')
8
9
  end
9
10
 
10
11
  def name_for(order)
@@ -121,10 +121,7 @@ module Spree
121
121
  end
122
122
 
123
123
  def related_products
124
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
125
- ProductsHelper#related_products is deprecated and will be removed in Spree 5.0.
126
- Please use ProductsHelper#relations from now on.
127
- DEPRECATION
124
+ Spree::Deprecation.warn('ProductsHelper#related_products is deprecated and will be removed in Spree 6.0. Please use ProductsHelper#relations from now on.')
128
125
 
129
126
  return [] unless @product.respond_to?(:has_related_products?)
130
127
 
@@ -830,6 +830,10 @@ module Spree
830
830
  csv_lines
831
831
  end
832
832
 
833
+ def all_line_items
834
+ line_items
835
+ end
836
+
833
837
  private
834
838
 
835
839
  def link_by_email
@@ -42,19 +42,6 @@ module Spree
42
42
  # virtual attributes for use with AJAX completion stuff
43
43
  delegate :name, :presentation, to: :property, prefix: true, allow_nil: true
44
44
 
45
- def property_name=(name)
46
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
47
- `ProductProperty#property_name=` is deprecated and will be removed in Spree 5.0.
48
- DEPRECATION
49
- if name.present?
50
- self.property = if Property.where(name: name).exists?
51
- Property.where(name: name).first
52
- else
53
- Property.create(name: name, presentation: name)
54
- end
55
- end
56
- end
57
-
58
45
  protected
59
46
 
60
47
  def param_candidate
@@ -54,8 +54,8 @@ module Spree
54
54
  template 'rails/application.rb', "#{dummy_path}/config/application.rb", force: true
55
55
  template 'rails/routes.rb', "#{dummy_path}/config/routes.rb", force: true
56
56
  template 'rails/test.rb', "#{dummy_path}/config/environments/test.rb", force: true
57
- template 'rails/script/rails', "#{dummy_path}/spec/dummy/script/rails", force: true
58
57
  template 'initializers/devise.rb', "#{dummy_path}/config/initializers/devise.rb", force: true
58
+ template "app/assets/config/manifest.js", "#{dummy_path}/app/assets/config/manifest.js", force: true
59
59
  end
60
60
 
61
61
  def test_dummy_inject_extension_requirements
@@ -2,9 +2,8 @@ require File.expand_path('../boot', __FILE__)
2
2
 
3
3
  require 'rails/all'
4
4
 
5
- Bundler.require(*Rails.groups(assets: %w(development test)))
5
+ Bundler.require(*Rails.groups)
6
6
 
7
7
  require '<%= lib_name %>'
8
8
 
9
9
  <%= application_definition %>
10
-
@@ -2,77 +2,6 @@ module Spree
2
2
  module Core
3
3
  module ControllerHelpers
4
4
  module Common
5
- extend ActiveSupport::Concern
6
- included do
7
- helper_method :title
8
- helper_method :title=
9
- helper_method :accurate_title
10
-
11
- layout :get_layout
12
-
13
- protected
14
-
15
- # can be used in views as well as controllers.
16
- # e.g. <% self.title = 'This is a custom title for this view' %>
17
- attr_writer :title
18
-
19
- def title
20
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
21
- ControllerHelpers::Common is deprecated and will be removed in Spree 5.0.
22
- DEPRECATION
23
- title_string = @title.present? ? @title : accurate_title
24
- if title_string.present?
25
- if Spree::Config[:always_put_site_name_in_title] && !title_string.include?(default_title)
26
- [title_string, default_title].join(" #{Spree::Config[:title_site_name_separator]} ")
27
- else
28
- title_string
29
- end
30
- else
31
- default_title
32
- end
33
- end
34
-
35
- def default_title
36
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
37
- ControllerHelpers::Common is deprecated and will be removed in Spree 5.0.
38
- DEPRECATION
39
- current_store.name
40
- end
41
-
42
- # this is a hook for subclasses to provide title
43
- def accurate_title
44
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
45
- ControllerHelpers::Common is deprecated and will be removed in Spree 5.0.
46
- DEPRECATION
47
- current_store.seo_title
48
- end
49
-
50
- private
51
-
52
- def set_user_language
53
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
54
- ControllerHelpers::Common#set_user_language is deprecated and will be removed in Spree 5.0.
55
- Please use `before_action :set_locale` instead
56
- DEPRECATION
57
-
58
- set_locale
59
- end
60
-
61
- # Returns which layout to render.
62
- #
63
- # You can set the layout you want to render inside your Spree configuration with the +:layout+ option.
64
- #
65
- # Default layout is: +app/views/spree/layouts/spree_application+
66
- #
67
- def get_layout
68
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
69
- ControllerHelpers::Common is deprecated and will be removed in Spree 5.0.
70
- DEPRECATION
71
- return unless defined?(Spree::Frontend)
72
-
73
- layout ||= Spree::Frontend::Config[:layout]
74
- end
75
- end
76
5
  end
77
6
  end
78
7
  end
@@ -42,7 +42,7 @@ module Spree
42
42
  Spree::Config = app.config.spree.preferences
43
43
  Spree::RuntimeConfig = app.config.spree.preferences # for compatibility
44
44
  Spree::Dependencies = app.config.spree.dependencies
45
- Spree::Deprecation = ActiveSupport::Deprecation.new
45
+ Spree::Deprecation = ActiveSupport::Deprecation.new('6.0', 'Spree')
46
46
  end
47
47
 
48
48
  initializer 'spree.register.calculators', before: :after_initialize do |app|
@@ -108,6 +108,16 @@ module Spree::Preferences::Preferable
108
108
  preference_keys.each { |pref| preferences[pref] = preference_default(pref) }
109
109
  end
110
110
 
111
+ def preference_change(name, changes_or_previous_changes)
112
+ preference_changes = changes_or_previous_changes.with_indifferent_access.fetch('preferences', [{}, {}])
113
+ before_preferences = preference_changes[0] || {}
114
+ after_preferences = preference_changes[1] || {}
115
+
116
+ return if before_preferences[name] == after_preferences[name]
117
+
118
+ [before_preferences[name], after_preferences[name]]
119
+ end
120
+
111
121
  private
112
122
 
113
123
  def convert_preference_value(value, type, nullable: false)
@@ -43,6 +43,34 @@ module Spree::Preferences
43
43
  define_method prefers_query_method(name) do
44
44
  preferences.fetch(name).to_b
45
45
  end
46
+
47
+ define_method preference_change_method(name) do
48
+ preference_change(name, changes) if respond_to?(:changes)
49
+ end
50
+
51
+ define_method preference_was_method(name) do
52
+ return unless respond_to?(:changes)
53
+
54
+ preference_change(name, changes)&.first || get_preference(name)
55
+ end
56
+
57
+ define_method preference_changed_method(name) do
58
+ respond_to?(:changes) && preference_change(name, changes).present?
59
+ end
60
+
61
+ define_method preference_previous_change_method(name) do
62
+ preference_change(name, previous_changes) if respond_to?(:previous_changes)
63
+ end
64
+
65
+ define_method preference_previous_was_method(name) do
66
+ return unless respond_to?(:previous_changes)
67
+
68
+ preference_change(name, previous_changes)&.first
69
+ end
70
+
71
+ define_method preference_previous_changed_method(name) do
72
+ respond_to?(:previous_changes) && preference_change(name, previous_changes).present?
73
+ end
46
74
  end
47
75
 
48
76
  def preference_getter_method(name)
@@ -68,5 +96,29 @@ module Spree::Preferences
68
96
  def prefers_query_method(name)
69
97
  "prefers_#{name}?".to_sym
70
98
  end
99
+
100
+ def preference_change_method(name)
101
+ "preferred_#{name}_change".to_sym
102
+ end
103
+
104
+ def preference_was_method(name)
105
+ "preferred_#{name}_was".to_sym
106
+ end
107
+
108
+ def preference_changed_method(name)
109
+ "preferred_#{name}_changed?".to_sym
110
+ end
111
+
112
+ def preference_previous_change_method(name)
113
+ "preferred_#{name}_previous_change".to_sym
114
+ end
115
+
116
+ def preference_previous_was_method(name)
117
+ "preferred_#{name}_previously_was".to_sym
118
+ end
119
+
120
+ def preference_previous_changed_method(name)
121
+ "preferred_#{name}_previously_changed?".to_sym
122
+ end
71
123
  end
72
124
  end
@@ -1,5 +1,5 @@
1
1
  module Spree
2
- VERSION = '5.1.0.beta'.freeze
2
+ VERSION = '5.1.0.beta2'.freeze
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -22,6 +22,7 @@ module Spree
22
22
  :option_type_attributes,
23
23
  :option_value_attributes,
24
24
  :page_attributes,
25
+ :page_block_attributes,
25
26
  :page_link_attributes,
26
27
  :page_section_attributes,
27
28
  :payment_attributes,
@@ -124,6 +125,8 @@ module Spree
124
125
 
125
126
  @@page_attributes = [:name, :slug, :meta_title, :meta_description, :meta_keywords]
126
127
 
128
+ @@page_block_attributes = [:type, :name, :position]
129
+
127
130
  @@page_link_attributes = [:linkable_id, :linkable_type, :position, :label, :url]
128
131
 
129
132
  @@page_section_attributes = [:type, :name, :position, :asset]
@@ -167,7 +170,7 @@ module Spree
167
170
 
168
171
  @@reimbursement_attributes = [return_items_attributes: [:id, :override_reimbursement_type_id, :pre_tax_amount, :exchange_variant_id]]
169
172
 
170
- @@reimbursement_type_attributes = [:name, :active]
173
+ @@reimbursement_type_attributes = [:name, :type, :active, :mutable]
171
174
 
172
175
  @@report_attributes = [:type, :date_from, :date_to, :currency]
173
176
 
@@ -6,98 +6,6 @@ module Spree
6
6
  included do
7
7
  routes { Spree::Core::Engine.routes }
8
8
  end
9
-
10
- def spree_get(action, parameters = nil, session = nil, flash = nil)
11
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
12
- ControllerRequests#spree_get is deprecated and will be removed in Spree 5.0.
13
- Please use get, params: {}
14
- DEPRECATION
15
- process_spree_action(action, parameters, session, flash, 'GET')
16
- end
17
-
18
- # Executes a request simulating POST HTTP method and set/volley the response
19
- def spree_post(action, parameters = nil, session = nil, flash = nil)
20
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
21
- ControllerRequests#spree_post is deprecated and will be removed in Spree 5.0.
22
- Please use post, params: {}
23
- DEPRECATION
24
- process_spree_action(action, parameters, session, flash, 'POST')
25
- end
26
-
27
- # Executes a request simulating PUT HTTP method and set/volley the response
28
- def spree_put(action, parameters = nil, session = nil, flash = nil)
29
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
30
- ControllerRequests#spree_put is deprecated and will be removed in Spree 5.0.
31
- Please use put, params: {}
32
- DEPRECATION
33
- process_spree_action(action, parameters, session, flash, 'PUT')
34
- end
35
-
36
- # # Executes a request simulating PATCH HTTP method and set/volley the response
37
- def spree_patch(action, parameters = nil, session = nil, flash = nil)
38
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
39
- ControllerRequests#spree_patch is deprecated and will be removed in Spree 5.0.
40
- Please use patch, params: {}
41
- DEPRECATION
42
- process_spree_action(action, parameters, session, flash, 'PATCH')
43
- end
44
-
45
- # Executes a request simulating DELETE HTTP method and set/volley the response
46
- def spree_delete(action, parameters = nil, session = nil, flash = nil)
47
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
48
- ControllerRequests#spree_delete is deprecated and will be removed in Spree 5.0.
49
- Please use delete, params: {}
50
- DEPRECATION
51
- process_spree_action(action, parameters, session, flash, 'DELETE')
52
- end
53
-
54
- def spree_xhr_get(action, parameters = nil, session = nil, flash = nil)
55
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
56
- ControllerRequests#spree_xhr_get is deprecated and will be removed in Spree 5.0.
57
- DEPRECATION
58
- process_spree_xhr_action(action, parameters, session, flash, :get)
59
- end
60
-
61
- def spree_xhr_post(action, parameters = nil, session = nil, flash = nil)
62
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
63
- ControllerRequests#spree_xhr_post is deprecated and will be removed in Spree 5.0.
64
- DEPRECATION
65
- process_spree_xhr_action(action, parameters, session, flash, :post)
66
- end
67
-
68
- def spree_xhr_put(action, parameters = nil, session = nil, flash = nil)
69
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
70
- ControllerRequests#spree_xhr_put is deprecated and will be removed in Spree 5.0.
71
- DEPRECATION
72
- process_spree_xhr_action(action, parameters, session, flash, :put)
73
- end
74
-
75
- def spree_xhr_patch(action, parameters = nil, session = nil, flash = nil)
76
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
77
- ControllerRequests#spree_xhr_patch is deprecated and will be removed in Spree 5.0.
78
- DEPRECATION
79
- process_spree_xhr_action(action, parameters, session, flash, :patch)
80
- end
81
-
82
- def spree_xhr_delete(action, parameters = nil, session = nil, flash = nil)
83
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
84
- ControllerRequests#spree_xhr_delete is deprecated and will be removed in Spree 5.0.
85
- DEPRECATION
86
- process_spree_xhr_action(action, parameters, session, flash, :delete)
87
- end
88
-
89
- private
90
-
91
- def process_spree_action(action, parameters = nil, session = nil, flash = nil, method = 'GET')
92
- parameters ||= {}
93
- process(action, method: method, params: parameters, session: session, flash: flash)
94
- end
95
-
96
- def process_spree_xhr_action(action, parameters = nil, session = nil, flash = nil, method = :get)
97
- parameters ||= {}
98
- parameters.reverse_merge!(format: :json)
99
- process(action, method: method, params: parameters, session: session, flash: flash, xhr: true)
100
- end
101
9
  end
102
10
  end
103
11
  end
@@ -16,6 +16,7 @@ FactoryBot.define do
16
16
  type { 'Spree::PageBlocks::Heading' }
17
17
  end
18
18
 
19
+ factory :buttons_block, traits: [:buttons], class: Spree::PageBlocks::Buttons
19
20
  factory :heading_block, traits: [:heading], class: Spree::PageBlocks::Heading
20
21
  end
21
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0.beta
4
+ version: 5.1.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2025-05-20 00:00:00.000000000 Z
13
+ date: 2025-05-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: i18n-tasks
@@ -35,7 +35,7 @@ dependencies:
35
35
  version: '7.2'
36
36
  - - "<"
37
37
  - !ruby/object:Gem::Version
38
- version: '8.0'
38
+ version: '8.1'
39
39
  type: :runtime
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: '7.2'
46
46
  - - "<"
47
47
  - !ruby/object:Gem::Version
48
- version: '8.0'
48
+ version: '8.1'
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: activemerchant
51
51
  requirement: !ruby/object:Gem::Requirement
@@ -1024,7 +1024,6 @@ files:
1024
1024
  - app/sorters/spree/classifications/sort.rb
1025
1025
  - app/sorters/spree/orders/sort.rb
1026
1026
  - app/sorters/spree/products/sort.rb
1027
- - app/validators/db_maximum_length_validator.rb
1028
1027
  - app/validators/email_validator.rb
1029
1028
  - app/validators/spree/url_validator.rb
1030
1029
  - app/views/action_text/video_embeds/_thumbnail.html.erb
@@ -1166,12 +1165,12 @@ files:
1166
1165
  - lib/generators/spree/authentication/devise/devise_generator.rb
1167
1166
  - lib/generators/spree/authentication/devise/templates/authentication_helpers.rb.tt
1168
1167
  - lib/generators/spree/dummy/dummy_generator.rb
1168
+ - lib/generators/spree/dummy/templates/app/assets/config/manifest.js
1169
1169
  - lib/generators/spree/dummy/templates/initializers/devise.rb
1170
1170
  - lib/generators/spree/dummy/templates/rails/application.rb
1171
1171
  - lib/generators/spree/dummy/templates/rails/boot.rb
1172
1172
  - lib/generators/spree/dummy/templates/rails/database.yml
1173
1173
  - lib/generators/spree/dummy/templates/rails/routes.rb
1174
- - lib/generators/spree/dummy/templates/rails/script/rails
1175
1174
  - lib/generators/spree/dummy/templates/rails/test.rb
1176
1175
  - lib/generators/spree/dummy_model/dummy_model_generator.rb
1177
1176
  - lib/generators/spree/dummy_model/templates/migration.rb.tt
@@ -1345,9 +1344,9 @@ licenses:
1345
1344
  - BSD-3-Clause
1346
1345
  metadata:
1347
1346
  bug_tracker_uri: https://github.com/spree/spree/issues
1348
- changelog_uri: https://github.com/spree/spree/releases/tag/v5.1.0.beta
1347
+ changelog_uri: https://github.com/spree/spree/releases/tag/v5.1.0.beta2
1349
1348
  documentation_uri: https://docs.spreecommerce.org/
1350
- source_code_uri: https://github.com/spree/spree/tree/v5.1.0.beta
1349
+ source_code_uri: https://github.com/spree/spree/tree/v5.1.0.beta2
1351
1350
  post_install_message:
1352
1351
  rdoc_options: []
1353
1352
  require_paths:
@@ -1,16 +0,0 @@
1
- ##
2
- # Validates a field based on the maximum length of the underlying DB field, if there is one.
3
- class DbMaximumLengthValidator < ActiveModel::EachValidator
4
- def validate_each(record, attribute, value)
5
- Spree::Deprecation.warn(<<-DEPRECATION, caller)
6
- `DbMaximumLengthValidator` is deprecated and will be removed in Spree 5.0.
7
- Please remove any `db_maximum_length: true` validations from your codebase
8
- DEPRECATION
9
-
10
- limit = record.class.columns_hash[attribute.to_s].limit
11
- value = record[attribute.to_sym]
12
- if value && limit && value.to_s.length > limit
13
- record.errors.add(attribute.to_sym, :too_long, count: limit)
14
- end
15
- end
16
- end
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'