1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix options overwritten by super

This commit is contained in:
Jose Añasco 2014-12-08 20:14:34 -05:00
parent 8e52954349
commit 112274ebff
3 changed files with 15 additions and 11 deletions

View file

@ -3,20 +3,18 @@ module ActionView
module Tags # :nodoc:
class SearchField < TextField # :nodoc:
def render
options = @options.stringify_keys
if options["autosave"]
if options["autosave"] == true
options["autosave"] = request.host.split(".").reverse.join(".")
super do |options|
if options["autosave"]
if options["autosave"] == true
options["autosave"] = request.host.split(".").reverse.join(".")
end
options["results"] ||= 10
end
options["results"] ||= 10
end
if options["onsearch"]
options["incremental"] = true unless options.has_key?("incremental")
if options["onsearch"]
options["incremental"] = true unless options.has_key?("incremental")
end
end
super
end
end
end

View file

@ -11,6 +11,7 @@ module ActionView
options["size"] = options["maxlength"] unless options.key?("size")
options["type"] ||= field_type
options["value"] = options.fetch("value") { value_before_type_cast(object) } unless field_type == "file"
yield options if block_given?
add_default_name_and_id(options)
tag("input", options)
end

View file

@ -928,6 +928,11 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal(expected, search_field("contact", "notes_query"))
end
def test_search_field_with_onsearch_value
expected = %{<input onsearch="true" type="search" name="contact[notes_query]" id="contact_notes_query" incremental="true" />}
assert_dom_equal(expected, search_field("contact", "notes_query", onsearch: true))
end
def test_telephone_field
expected = %{<input id="user_cell" name="user[cell]" type="tel" />}
assert_dom_equal(expected, telephone_field("user", "cell"))