提交 a4acb4da 编写于 作者: G Godfrey Chan 提交者: GitHub

Merge pull request #25287 from marekkirejczyk/fix_25267

Make select_year work with include_position: true option, fix #25267
......@@ -1059,7 +1059,7 @@ def input_name_from_type(type)
prefix = @options[:prefix] || ActionView::Helpers::DateTimeSelector::DEFAULT_PREFIX
prefix += "[#{@options[:index]}]" if @options.has_key?(:index)
field_name = @options[:field_name] || type
field_name = @options[:field_name] || type.to_s
if @options[:include_position]
field_name += "(#{ActionView::Helpers::DateTimeSelector::POSITION[type]}i)"
end
......
......@@ -534,6 +534,13 @@ def test_select_year_with_custom_with_css_classes
assert_dom_equal expected, select_year(nil, start_year: 2003, end_year: 2005, with_css_classes: { year: 'my-year' })
end
def test_select_year_with_position
expected = %(<select id="date_year_1i" name="date[year(1i)]">\n)
expected << %(<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
expected << "</select>\n"
assert_dom_equal expected, select_year(Date.current, include_position: true, start_year: 2003, end_year: 2005)
end
def test_select_hour
expected = %(<select id="date_hour" name="date[hour]">\n)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册