aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/form_collections_helper_test.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2012-02-14 01:28:22 -0800
committerJosé Valim <jose.valim@plataformatec.com.br>2012-02-14 01:28:22 -0800
commit65ffcec5a64053576b2597d3e40fd1d0176c7129 (patch)
tree3e5ed23429f8c403ea005cefaf5c66e569e8d691 /actionpack/test/template/form_collections_helper_test.rb
parentc5b90a6ab1430107131f0cb363e2697a4ecb2714 (diff)
parenta10ed70999935cf86bd9a170ce3d4748631968ca (diff)
downloadrails-65ffcec5a64053576b2597d3e40fd1d0176c7129.tar.gz
rails-65ffcec5a64053576b2597d3e40fd1d0176c7129.tar.bz2
rails-65ffcec5a64053576b2597d3e40fd1d0176c7129.zip
Merge pull request #5032 from carlosantoniodasilva/collection-helpers-object
Allow collection helpers with block to access current object in the collection
Diffstat (limited to 'actionpack/test/template/form_collections_helper_test.rb')
-rw-r--r--actionpack/test/template/form_collections_helper_test.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/actionpack/test/template/form_collections_helper_test.rb b/actionpack/test/template/form_collections_helper_test.rb
index a4aea8ca56..4d878635ef 100644
--- a/actionpack/test/template/form_collections_helper_test.rb
+++ b/actionpack/test/template/form_collections_helper_test.rb
@@ -123,6 +123,19 @@ class FormCollectionsHelperTest < ActionView::TestCase
end
end
+ test 'collection radio with block helpers allows access to the current object item in the collection to access extra properties' do
+ with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s do |b|
+ b.label(:class => b.object) { b.radio_button + b.text }
+ end
+
+ assert_select 'label.true[for=user_active_true]', 'true' do
+ assert_select 'input#user_active_true[type=radio]'
+ end
+ assert_select 'label.false[for=user_active_false]', 'false' do
+ assert_select 'input#user_active_false[type=radio]'
+ end
+ end
+
test 'collection radio buttons with fields for' do
collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')]
@output_buffer = fields_for(:post) do |p|
@@ -298,4 +311,17 @@ class FormCollectionsHelperTest < ActionView::TestCase
assert_select 'input#user_active_false[type=checkbox]'
end
end
+
+ test 'collection check boxes with block helpers allows access to the current object item in the collection to access extra properties' do
+ with_collection_check_boxes :user, :active, [true, false], :to_s, :to_s do |b|
+ b.label(:class => b.object) { b.check_box + b.text }
+ end
+
+ assert_select 'label.true[for=user_active_true]', 'true' do
+ assert_select 'input#user_active_true[type=checkbox]'
+ end
+ assert_select 'label.false[for=user_active_false]', 'false' do
+ assert_select 'input#user_active_false[type=checkbox]'
+ end
+ end
end