Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #4574 from ihid/master

Fixed regression - unable to use a range as choices for form.select.
  • Loading branch information...
commit c3aaacafaa0576d3464b568e8fa693e72699c66d 2 parents df15eb0 + 2ee8c6a
@josevalim josevalim authored
View
1  actionpack/lib/action_view/helpers/tags/select.rb
@@ -4,6 +4,7 @@ module Tags
class Select < Base #:nodoc:
def initialize(object_name, method_name, template_object, choices, options, html_options)
@choices = choices
+ @choices = @choices.to_a if @choices.is_a?(Range)
@html_options = html_options
super(object_name, method_name, template_object, options)
View
16 actionpack/test/template/form_options_helper_test.rb
@@ -144,6 +144,13 @@ def test_boolean_array_options_for_select_with_selection_and_disabled_value
)
end
+ def test_range_options_for_select
+ assert_dom_equal(
+ "<option value=\"1\">1</option>\n<option value=\"2\">2</option>\n<option value=\"3\">3</option>",
+ options_for_select(1..3)
+ )
+ end
+
def test_array_options_for_string_include_in_other_string_bug_fix
assert_dom_equal(
"<option value=\"ruby\">ruby</option>\n<option value=\"rubyonrails\" selected=\"selected\">rubyonrails</option>",
@@ -671,6 +678,15 @@ def test_select_with_disabled_array
)
end
+ def test_select_with_range
+ @post = Post.new
+ @post.category = 0
+ assert_dom_equal(
+ "<select id=\"post_category\" name=\"post[category]\"><option value=\"1\">1</option>\n<option value=\"2\">2</option>\n<option value=\"3\">3</option></select>",
+ select("post", "category", 1..3)
+ )
+ end
+
def test_collection_select
@post = Post.new
@post.author_name = "Babe"
Please sign in to comment.
Something went wrong with that request. Please try again.