aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-11-10 22:08:20 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-11-10 22:08:20 +0000
commitb81c46e6bd6997bf6637b5086bbb9cbb32664974 (patch)
treeff0a624cefac65f0f48e72d120383dd10b730c7a /actionpack/test
parent41e4173fd6ce8d6302e096e46976bfb79fb8aeb5 (diff)
downloadrails-b81c46e6bd6997bf6637b5086bbb9cbb32664974.tar.gz
rails-b81c46e6bd6997bf6637b5086bbb9cbb32664974.tar.bz2
rails-b81c46e6bd6997bf6637b5086bbb9cbb32664974.zip
options_for_select allows any objects which respond_to? :first and :last rather than restricting to Array and Range. Closes #2824. References [2126].
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2977 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/form_options_helper_test.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb
index cc68312fb8..36d68492ec 100644
--- a/actionpack/test/template/form_options_helper_test.rb
+++ b/actionpack/test/template/form_options_helper_test.rb
@@ -103,25 +103,35 @@ class FormOptionsHelperTest < Test::Unit::TestCase
options_for_select([ "ruby", "rubyonrails" ], "ruby")
)
end
-
+
def test_hash_options_for_select
assert_dom_equal(
"<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\">$</option>",
options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" })
)
- end
-
- def test_hash_options_for_select_with_selection
assert_dom_equal(
"<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, "Dollar")
)
+ assert_dom_equal(
+ "<option value=\"&lt;Kroner&gt;\" selected=\"selected\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
+ options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, [ "Dollar", "<Kroner>" ])
+ )
end
- def test_hash_options_for_select_with_selection
+ def test_ducktyped_options_for_select
+ quack = Struct.new(:first, :last)
+ assert_dom_equal(
+ "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\">$</option>",
+ options_for_select([quack.new("<DKR>", "<Kroner>"), quack.new("$", "Dollar")])
+ )
+ assert_dom_equal(
+ "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
+ options_for_select([quack.new("<DKR>", "<Kroner>"), quack.new("$", "Dollar")], "Dollar")
+ )
assert_dom_equal(
"<option value=\"&lt;Kroner&gt;\" selected=\"selected\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
- options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, [ "Dollar", "<Kroner>" ])
+ options_for_select([quack.new("<DKR>", "<Kroner>"), quack.new("$", "Dollar")], ["Dollar", "<Kroner>"])
)
end