Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove support for deprecated validation message interpolation format

  • Loading branch information...
commit a7ccc7c79fa69cea3b7d19bcaa4df3c2932238d8 1 parent e9c5750
@jeremy jeremy authored
View
1  activerecord/lib/active_record.rb
@@ -75,5 +75,4 @@ module ConnectionAdapters
end
end
-require 'active_record/i18n_interpolation_deprecation'
I18n.load_path << File.dirname(__FILE__) + '/active_record/locale/en.yml'
View
26 activerecord/lib/active_record/i18n_interpolation_deprecation.rb
@@ -1,26 +0,0 @@
-# Deprecates the use of the former message interpolation syntax in activerecord
-# as in "must have %d characters". The new syntax uses explicit variable names
-# as in "{{value}} must have {{count}} characters".
-
-require 'i18n/backend/simple'
-module I18n
- module Backend
- class Simple
- DEPRECATED_INTERPOLATORS = { '%d' => '{{count}}', '%s' => '{{value}}' }
-
- protected
- def interpolate_with_deprecated_syntax(locale, string, values = {})
- return string unless string.is_a?(String)
-
- string = string.gsub(/%d|%s/) do |s|
- instead = DEPRECATED_INTERPOLATORS[s]
- ActiveSupport::Deprecation.warn "using #{s} in messages is deprecated; use #{instead} instead."
- instead
- end
-
- interpolate_without_deprecated_syntax(locale, string, values)
- end
- alias_method_chain :interpolate, :deprecated_syntax
- end
- end
-end
View
34 activerecord/test/cases/validations_i18n_test.rb
@@ -38,35 +38,17 @@ def reset_callbacks(*models)
end
end
- def test_default_error_messages_is_deprecated
- assert_deprecated('ActiveRecord::Errors.default_error_messages') do
- ActiveRecord::Errors.default_error_messages
+ def test_percent_s_interpolation_syntax_in_error_messages_was_deprecated
+ assert_not_deprecated do
+ default = "%s interpolation syntax was deprecated"
+ assert_equal default, I18n.t(:does_not_exist, :default => default, :value => 'this')
end
end
- def test_percent_s_interpolation_syntax_in_error_messages_still_works
- ActiveSupport::Deprecation.silence do
- result = I18n.t :does_not_exist, :default => "%s interpolation syntax is deprecated", :value => 'this'
- assert_equal result, "this interpolation syntax is deprecated"
- end
- end
-
- def test_percent_s_interpolation_syntax_in_error_messages_is_deprecated
- assert_deprecated('using %s in messages') do
- I18n.t :does_not_exist, :default => "%s interpolation syntax is deprected", :value => 'this'
- end
- end
-
- def test_percent_d_interpolation_syntax_in_error_messages_still_works
- ActiveSupport::Deprecation.silence do
- result = I18n.t :does_not_exist, :default => "%d interpolation syntaxes are deprecated", :count => 2
- assert_equal result, "2 interpolation syntaxes are deprecated"
- end
- end
-
- def test_percent_d_interpolation_syntax_in_error_messages_is_deprecated
- assert_deprecated('using %d in messages') do
- I18n.t :does_not_exist, :default => "%d interpolation syntaxes are deprected", :count => 2
+ def test_percent_d_interpolation_syntax_in_error_messages_was_deprecated
+ assert_not_deprecated do
+ default = "%d interpolation syntaxes are deprecated"
+ assert_equal default, I18n.t(:does_not_exist, :default => default, :count => 2)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.