This repository was archived by the owner on Dec 28, 2023. It is now read-only.
Commit a6ea927 1 parent 8fc94e7 commit a6ea927 Copy full SHA for a6ea927
File tree 2 files changed +10
-2
lines changed
2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ def locale
9
9
# Sets the current locale pseudo-globally, i.e. in the Thread.current hash.
10
10
def locale = ( locale )
11
11
I18n . enforce_available_locales! ( locale )
12
- @locale = locale . to_sym rescue nil
12
+ @locale = locale && locale . to_sym
13
13
end
14
14
15
15
# Returns the current backend. Defaults to +Backend::Simple+.
@@ -30,7 +30,7 @@ def default_locale
30
30
# Sets the current default locale. Used to set a custom default locale.
31
31
def default_locale = ( locale )
32
32
I18n . enforce_available_locales! ( locale )
33
- @@default_locale = locale . to_sym rescue nil
33
+ @@default_locale = locale && locale . to_sym
34
34
end
35
35
36
36
# Returns an array of locales for which translations are available.
Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ def setup
37
37
end
38
38
end
39
39
40
+ test "default_locale= doesn't ignore junk" do
41
+ assert_raise ( NoMethodError ) { I18n . default_locale = Class }
42
+ end
43
+
40
44
test "raises an I18n::InvalidLocale exception when setting an unavailable default locale" do
41
45
begin
42
46
I18n . config . enforce_available_locales = true
@@ -57,6 +61,10 @@ def setup
57
61
I18n . locale = :en
58
62
end
59
63
64
+ test "locale= doesn't ignore junk" do
65
+ assert_raise ( NoMethodError ) { I18n . locale = Class }
66
+ end
67
+
60
68
test "raises an I18n::InvalidLocale exception when setting an unavailable locale" do
61
69
begin
62
70
I18n . config . enforce_available_locales = true
You can’t perform that action at this time.
0 commit comments