Permalink
Browse files

Accept symbols and strings in #priority_languages_array

  • Loading branch information...
1 parent 253d2cc commit f8e4048f714269fdf05de3ce06a8b586b48959f7 @davec committed Apr 10, 2011
Showing with 6 additions and 4 deletions.
  1. +1 −1 lib/localized_language_select.rb
  2. +5 −3 test/localized_language_select_test.rb
View
2 lib/localized_language_select.rb
@@ -50,7 +50,7 @@ def include_language?(key, options)
# # => [ ['German', 'de'], ['French', 'fr'], ['English', 'en'] ]
def priority_languages_array(language_codes=[])
languages = I18n.translate(:languages)
- language_codes.map { |code| [languages[code], code.to_s] }
+ language_codes.map { |code| [languages[code.to_sym], code.to_s] }
end
end
end
View
8 test/localized_language_select_test.rb
@@ -54,8 +54,11 @@ def test_should_return_localized_country_option_tags
end
def test_should_return_priority_languages_first
- assert localized_language_options_for_select(nil, [:es, :fr, :"nl-BE"]) =~ Regexp.new(
- Regexp.escape("<option value=\"es\">Spanish</option>\n<option value=\"fr\">French</option>\n<option value=\"nl-BE\">Flemish</option><option value=\"\" disabled=\"disabled\">-------------</option>\n<option value=\"ab\">Abkhazian</option>\n"))
+ # Once with symbols, and once with strings
+ [ [ :es, :fr, :"nl-BE" ], [ "es", "fr", "nl-BE" ] ].each do |langs|
+ assert localized_language_options_for_select(nil, langs) =~ Regexp.new(
+ Regexp.escape("<option value=\"es\">Spanish</option>\n<option value=\"fr\">French</option>\n<option value=\"nl-BE\">Flemish</option><option value=\"\" disabled=\"disabled\">-------------</option>\n<option value=\"ab\">Abkhazian</option>\n"))
+ end
end
def test_i18n_should_know_about_languages
@@ -95,7 +98,6 @@ def test_localized_countries_array_rejects_on_except_option
assert !list.include?(['Afrikaans', 'af'])
end
-
# private
def setup

0 comments on commit f8e4048

Please sign in to comment.