Permalink
Browse files

Allow passing either uppercase or lower case country codes in priorit…

…y countries
  • Loading branch information...
1 parent 4bafeeb commit c96ea301df65b75df141a71d612df022dc4a7067 @karmi karmi committed Sep 30, 2009
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/localized_country_select.rb
  2. +6 −0 test/localized_country_select_test.rb
@@ -31,7 +31,7 @@ def localized_countries_array
# # => [ ['Taiwan', 'TW'], ['China', 'CN'] ]
def priority_countries_array(country_codes=[])
countries = I18n.translate(:countries)
- country_codes.map { |code| [countries[code.to_sym], code.to_s.upcase] }
+ country_codes.map { |code| [countries[code.to_s.upcase.to_sym], code.to_s.upcase] }
end
end
end
@@ -89,6 +89,12 @@ def test_priority_countries_allows_passing_either_symbol_or_string
assert_equal [ ['United States', 'US'], ['Canada', 'CA'] ], LocalizedCountrySelect::priority_countries_array(['US', 'CA'])
end
+ def test_priority_countries_allows_passing_upcase_or_lowercase
+ I18n.locale = 'en'
+ assert_equal [ ['United States', 'US'], ['Canada', 'CA'] ], LocalizedCountrySelect::priority_countries_array(['us', 'ca'])
+ assert_equal [ ['United States', 'US'], ['Canada', 'CA'] ], LocalizedCountrySelect::priority_countries_array([:us, :ca])
+ end
+
private
def setup

0 comments on commit c96ea30

Please sign in to comment.