Skip to content

Commit

Permalink
subregion_select_tag no longer ignores the priority option. Closes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
jim committed Jun 5, 2012
1 parent 3df0c7f commit 219b8e9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/carmen/rails/action_view/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ def country_select_tag(name, value, options={})
def subregion_select_tag(name, value, parent_region_or_code, options = {}, html_options = {})
options.stringify_keys!
parent_region = determine_parent(parent_region_or_code)
priority_regions = options.delete(:priority) || []
priority_regions = options.delete('priority') || []
opts = region_options_for_select(parent_region.subregions, value, :priority => priority_regions)
html_options = {"name" => name,
"id" => sanitize_to_id(name)}.update(options.stringify_keys)
"id" => sanitize_to_id(name)}.update(html_options.stringify_keys)
content_tag(:select, opts, html_options)
end

Expand Down
17 changes: 16 additions & 1 deletion spec/carmen/action_view/helpers/form_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_subregion_selected_value
assert_select('option[selected="selected"][value="AO"]')
end

def test_basic_subregion_select
def test_basic_subregion_select_tag
oceania = Carmen::Country.coded('OC')
expected = <<-HTML
<select id="subregion_code" name="subregion_code">
Expand All @@ -125,6 +125,21 @@ def test_basic_subregion_select
assert_equal_markup(expected, html)
end

def test_subregion_select_tag_with_priority
oceania = Carmen::Country.coded('OC')
expected = <<-HTML
<select id="subregion_code" name="subregion_code">
<option value="AO">Airstrip One</option>
<option disabled>-------------</option>
<option value="AO">Airstrip One</option>
</select>
HTML

html = subregion_select_tag(:subregion_code, nil, oceania, :priority => ['AO'])

assert_equal_markup(expected, html)
end

def test_region_options_for_select
regions = Carmen::Country.all
expected = <<-HTML
Expand Down

0 comments on commit 219b8e9

Please sign in to comment.