Skip to content

Commit

Permalink
Raise a runtime error if any supplied priority_countries are not in t…
Browse files Browse the repository at this point in the history
…he main list

Without this, it's easy to end up with messy data if one (ahem) accidentally includes "USA" in priority_countries instead of "United States"...
  • Loading branch information
purcell committed Oct 13, 2011
1 parent dd7e03d commit 8da0643
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/country-select.rb
Expand Up @@ -15,6 +15,9 @@ def country_options_for_select(selected = nil, priority_countries = nil)
country_options = ""

if priority_countries
if (unlisted = priority_countries - COUNTRIES).any?
raise RuntimeError.new("Supplied priority countries are not in the main list: #{unlisted}")
end
country_options += options_for_select(priority_countries, selected)
country_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
end
Expand Down

0 comments on commit 8da0643

Please sign in to comment.