aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-01-14 00:56:29 +0100
committerJosé Valim <jose.valim@gmail.com>2010-01-14 01:07:03 +0100
commit214b548485f9313639059e8de1ad08611f734fe2 (patch)
treefb6701f290abf58c31f12b4d2e0a9a094dc3a995 /actionpack/test
parentd50bf47b008ae4c1a84ccc44e8fc7633bfffa650 (diff)
downloadrails-214b548485f9313639059e8de1ad08611f734fe2.tar.gz
rails-214b548485f9313639059e8de1ad08611f734fe2.tar.bz2
rails-214b548485f9313639059e8de1ad08611f734fe2.zip
Make check boxes accept :multiple as option so they can handle collections (such as HABTM).
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/lib/controller/fake_models.rb2
-rw-r--r--actionpack/test/template/form_helper_test.rb13
2 files changed, 14 insertions, 1 deletions
diff --git a/actionpack/test/lib/controller/fake_models.rb b/actionpack/test/lib/controller/fake_models.rb
index b0e5d7a94c..7346cb22bc 100644
--- a/actionpack/test/lib/controller/fake_models.rb
+++ b/actionpack/test/lib/controller/fake_models.rb
@@ -69,7 +69,7 @@ class Post < Struct.new(:title, :author_name, :body, :secret, :written_on, :cost
attr_accessor :author
def author_attributes=(attributes); end
- attr_accessor :comments
+ attr_accessor :comments, :comment_ids
def comments_attributes=(attributes); end
attr_accessor :tags
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index 2f6d97de3d..7712883e9c 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -245,6 +245,19 @@ class FormHelperTest < ActionView::TestCase
)
end
+ def test_check_box_with_multiple_behavior
+ @post.comment_ids = [2,3]
+ assert_dom_equal(
+ '<input name="post[comment_ids][]" type="hidden" value="0" /><input id="post_comment_ids_1" name="post[comment_ids][]" type="checkbox" value="1" />',
+ check_box("post", "comment_ids", { :multiple => true }, 1)
+ )
+ assert_dom_equal(
+ '<input name="post[comment_ids][]" type="hidden" value="0" /><input checked="checked" id="post_comment_ids_3" name="post[comment_ids][]" type="checkbox" value="3" />',
+ check_box("post", "comment_ids", { :multiple => true }, 3)
+ )
+ end
+
+
def test_checkbox_disabled_still_submits_checked_value
assert_dom_equal(
'<input name="post[secret]" type="hidden" value="1" /><input checked="checked" disabled="disabled" id="post_secret" name="post[secret]" type="checkbox" value="1" />',