Skip to content

Commit

Permalink
Fix passing {:object=>object} into Rails4 ActionView::Helpers::Tags::…
Browse files Browse the repository at this point in the history
…Base.new
  • Loading branch information
bshelton229 committed Jan 9, 2014
1 parent 076dd25 commit dbbb1ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/carmen/rails/action_view/form_helper.rb
Expand Up @@ -24,7 +24,7 @@ module FormOptionsHelper
# Returns an `html_safe` string containing the HTML for a select element.
def subregion_select(object, method, parent_region_or_code, options={}, html_options={})
parent_region = determine_parent(parent_region_or_code)
tag = instance_tag(object, method, self, options.delete(:object))
tag = instance_tag(object, method, self, options)
tag.to_region_select_tag(parent_region, options, html_options)
end

Expand Down Expand Up @@ -62,7 +62,7 @@ def country_select(object, method, *args)

html_options ||= {}

tag = instance_tag(object, method, self, options.delete(:object))
tag = instance_tag(object, method, self, options)
tag.to_region_select_tag(Carmen::World.instance, options, html_options)
end

Expand Down Expand Up @@ -160,7 +160,7 @@ def subregion_select_tag(name, value, parent_region_or_code, options = {}, html_

def instance_tag(object_name, method_name, template_object, options = {})
if Rails::VERSION::MAJOR == 3
InstanceTag.new(object_name, method_name, template_object, options)
InstanceTag.new(object_name, method_name, template_object, options.delete(:object))
else
ActionView::Helpers::Tags::Base.new(object_name, method_name, template_object, options || {})
end
Expand Down
8 changes: 8 additions & 0 deletions test/carmen/action_view/helpers/form_helper_test.rb
Expand Up @@ -33,6 +33,14 @@ def test_country_selected_value
assert_select('option[selected="selected"][value="OC"]')
end

def test_country_selected_object_option
@object.country_code = 'OC'
override_object = OpenStruct.new(:country_code => 'ES')
@html = country_select(@object, :country_code, {:object => override_object})

assert_select('option[selected="selected"][value="ES"]')
end

def test_basic_country_select_tag
html = country_select_tag('attribute_name', nil)
expected = <<-HTML
Expand Down

0 comments on commit dbbb1ab

Please sign in to comment.