Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix instance variable not defined warnings due to added deprecations #234

Merged
merged 1 commit into from

2 participants

@carlosantoniodasilva
Collaborator

Also fix the rescue_format deprecation, it seems it was never being triggered because it was checking for the existence of a not yet defined variable.


On a side note, I believe tests that rely on force_invalid_locale are broken, because the locale option will never be "invalid" since it's going to use the default locale instead, thus no exception is raised.

I can work on a fix for that later if you want, after finishing up a couple things related to I18n deprecations in Rails, just let me know.

@carlosantoniodasilva carlosantoniodasilva Fix instance variable not defined warnings due to added deprecations
Also fix the rescue_format deprecation, it seems it was never being
triggered because it was checking for the existence of a not yet defined
variable.
3d03935
@tigrish tigrish merged commit 8fc94e7 into svenfuchs:master
@carlosantoniodasilva carlosantoniodasilva deleted the carlosantoniodasilva:ca-fix-warnings branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 12, 2013
  1. @carlosantoniodasilva

    Fix instance variable not defined warnings due to added deprecations

    carlosantoniodasilva authored
    Also fix the rescue_format deprecation, it seems it was never being
    triggered because it was checking for the existence of a not yet defined
    variable.
This page is out of date. Refresh to see the latest.
View
4 lib/i18n.rb
@@ -358,8 +358,8 @@ def default_exception_handler(exception, locale, key, options)
end
def handle_enforce_available_locales_deprecation
- if config.enforce_available_locales.nil? && !@unenforced_available_locales_deprecation
- $stderr.puts "[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message."
+ if config.enforce_available_locales.nil? && !defined?(@unenforced_available_locales_deprecation)
+ $stderr.puts "[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message."
@unenforced_available_locales_deprecation = true
end
end
View
2  lib/i18n/exceptions.rb
@@ -13,7 +13,7 @@ def call(exception, locale, key, options)
# TODO: this block is to be replaced by `exception.message` when
# rescue_format is removed
if options[:rescue_format] == :html
- if @rescue_format_deprecation
+ if !defined?(@rescue_format_deprecation)
$stderr.puts "[DEPRECATED] I18n's :recue_format option will be removed from a future release. All exception messages will be plain text. If you need the exception handler to return an html format please set or pass a custom exception handler."
@rescue_format_deprecation = true
end
View
2  test/i18n/exceptions_test.rb
@@ -3,7 +3,7 @@
class I18nExceptionsTest < Test::Unit::TestCase
def test_invalid_locale_stores_locale
force_invalid_locale
- rescue I18n::ArgumentError => e
+ rescue I18n::ArgumentError => exception
assert_nil exception.locale
end
Something went wrong with that request. Please try again.