aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/form_helper_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-06-02 13:32:58 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2008-06-02 21:32:50 -0700
commit0bdb7d353b4ac6f5470884360f9a480a16bd709c (patch)
tree53d266015cf696c280b9ba37995c9d1f6bd02358 /actionpack/test/template/form_helper_test.rb
parent933697a5fc5f4c56c4fd7fbbd31b8973df9c1054 (diff)
downloadrails-0bdb7d353b4ac6f5470884360f9a480a16bd709c.tar.gz
rails-0bdb7d353b4ac6f5470884360f9a480a16bd709c.tar.bz2
rails-0bdb7d353b4ac6f5470884360f9a480a16bd709c.zip
Work with @output_buffer instead of _erbout
Diffstat (limited to 'actionpack/test/template/form_helper_test.rb')
-rw-r--r--actionpack/test/template/form_helper_test.rb260
1 files changed, 130 insertions, 130 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index af99e6243d..65984fac44 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -337,14 +337,14 @@ class FormHelperTest < ActionView::TestCase
end
def test_form_for
- _erbout = ''
+ @output_buffer = ''
form_for(:post, @post, :html => { :id => 'create-post' }) do |f|
- _erbout.concat f.label(:title)
- _erbout.concat f.text_field(:title)
- _erbout.concat f.text_area(:body)
- _erbout.concat f.check_box(:secret)
- _erbout.concat f.submit('Create post')
+ @output_buffer.concat f.label(:title)
+ @output_buffer.concat f.text_field(:title)
+ @output_buffer.concat f.text_area(:body)
+ @output_buffer.concat f.check_box(:secret)
+ @output_buffer.concat f.submit('Create post')
end
expected =
@@ -357,16 +357,16 @@ class FormHelperTest < ActionView::TestCase
"<input name='commit' id='post_submit' type='submit' value='Create post' />" +
"</form>"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_form_for_with_method
- _erbout = ''
+ @output_buffer = ''
form_for(:post, @post, :html => { :id => 'create-post', :method => :put }) do |f|
- _erbout.concat f.text_field(:title)
- _erbout.concat f.text_area(:body)
- _erbout.concat f.check_box(:secret)
+ @output_buffer.concat f.text_field(:title)
+ @output_buffer.concat f.text_area(:body)
+ @output_buffer.concat f.check_box(:secret)
end
expected =
@@ -378,16 +378,16 @@ class FormHelperTest < ActionView::TestCase
"<input name='post[secret]' type='hidden' value='0' />" +
"</form>"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_form_for_without_object
- _erbout = ''
+ @output_buffer = ''
form_for(:post, :html => { :id => 'create-post' }) do |f|
- _erbout.concat f.text_field(:title)
- _erbout.concat f.text_area(:body)
- _erbout.concat f.check_box(:secret)
+ @output_buffer.concat f.text_field(:title)
+ @output_buffer.concat f.text_area(:body)
+ @output_buffer.concat f.check_box(:secret)
end
expected =
@@ -398,17 +398,17 @@ class FormHelperTest < ActionView::TestCase
"<input name='post[secret]' type='hidden' value='0' />" +
"</form>"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_form_for_with_index
- _erbout = ''
+ @output_buffer = ''
form_for("post[]", @post) do |f|
- _erbout.concat f.label(:title)
- _erbout.concat f.text_field(:title)
- _erbout.concat f.text_area(:body)
- _erbout.concat f.check_box(:secret)
+ @output_buffer.concat f.label(:title)
+ @output_buffer.concat f.text_field(:title)
+ @output_buffer.concat f.text_area(:body)
+ @output_buffer.concat f.check_box(:secret)
end
expected =
@@ -420,16 +420,16 @@ class FormHelperTest < ActionView::TestCase
"<input name='post[123][secret]' type='hidden' value='0' />" +
"</form>"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_form_for_with_nil_index_option_override
- _erbout = ''
+ @output_buffer = ''
form_for("post[]", @post, :index => nil) do |f|
- _erbout.concat f.text_field(:title)
- _erbout.concat f.text_area(:body)
- _erbout.concat f.check_box(:secret)
+ @output_buffer.concat f.text_field(:title)
+ @output_buffer.concat f.text_area(:body)
+ @output_buffer.concat f.check_box(:secret)
end
expected =
@@ -440,14 +440,14 @@ class FormHelperTest < ActionView::TestCase
"<input name='post[][secret]' type='hidden' value='0' />" +
"</form>"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_nested_fields_for
- _erbout = ''
+ @output_buffer = ''
form_for(:post, @post) do |f|
f.fields_for(:comment, @post) do |c|
- _erbout.concat c.text_field(:title)
+ @output_buffer.concat c.text_field(:title)
end
end
@@ -455,16 +455,16 @@ class FormHelperTest < ActionView::TestCase
"<input name='post[comment][title]' size='30' type='text' id='post_comment_title' value='Hello World' />" +
"</form>"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_fields_for
- _erbout = ''
+ @output_buffer = ''
fields_for(:post, @post) do |f|
- _erbout.concat f.text_field(:title)
- _erbout.concat f.text_area(:body)
- _erbout.concat f.check_box(:secret)
+ @output_buffer.concat f.text_field(:title)
+ @output_buffer.concat f.text_area(:body)
+ @output_buffer.concat f.check_box(:secret)
end
expected =
@@ -473,16 +473,16 @@ class FormHelperTest < ActionView::TestCase
"<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
"<input name='post[secret]' type='hidden' value='0' />"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_fields_for_with_index
- _erbout = ''
+ @output_buffer = ''
fields_for("post[]", @post) do |f|
- _erbout.concat f.text_field(:title)
- _erbout.concat f.text_area(:body)
- _erbout.concat f.check_box(:secret)
+ @output_buffer.concat f.text_field(:title)
+ @output_buffer.concat f.text_area(:body)
+ @output_buffer.concat f.check_box(:secret)
end
expected =
@@ -491,16 +491,16 @@ class FormHelperTest < ActionView::TestCase
"<input name='post[123][secret]' checked='checked' type='checkbox' id='post_123_secret' value='1' />" +
"<input name='post[123][secret]' type='hidden' value='0' />"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_fields_for_with_nil_index_option_override
- _erbout = ''
+ @output_buffer = ''
fields_for("post[]", @post, :index => nil) do |f|
- _erbout.concat f.text_field(:title)
- _erbout.concat f.text_area(:body)
- _erbout.concat f.check_box(:secret)
+ @output_buffer.concat f.text_field(:title)
+ @output_buffer.concat f.text_area(:body)
+ @output_buffer.concat f.check_box(:secret)
end
expected =
@@ -509,16 +509,16 @@ class FormHelperTest < ActionView::TestCase
"<input name='post[][secret]' checked='checked' type='checkbox' id='post__secret' value='1' />" +
"<input name='post[][secret]' type='hidden' value='0' />"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_fields_for_with_index_option_override
- _erbout = ''
+ @output_buffer = ''
fields_for("post[]", @post, :index => "abc") do |f|
- _erbout.concat f.text_field(:title)
- _erbout.concat f.text_area(:body)
- _erbout.concat f.check_box(:secret)
+ @output_buffer.concat f.text_field(:title)
+ @output_buffer.concat f.text_area(:body)
+ @output_buffer.concat f.check_box(:secret)
end
expected =
@@ -527,15 +527,15 @@ class FormHelperTest < ActionView::TestCase
"<input name='post[abc][secret]' checked='checked' type='checkbox' id='post_abc_secret' value='1' />" +
"<input name='post[abc][secret]' type='hidden' value='0' />"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_fields_for_without_object
- _erbout = ''
+ @output_buffer = ''
fields_for(:post) do |f|
- _erbout.concat f.text_field(:title)
- _erbout.concat f.text_area(:body)
- _erbout.concat f.check_box(:secret)
+ @output_buffer.concat f.text_field(:title)
+ @output_buffer.concat f.text_area(:body)
+ @output_buffer.concat f.check_box(:secret)
end
expected =
@@ -544,15 +544,15 @@ class FormHelperTest < ActionView::TestCase
"<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
"<input name='post[secret]' type='hidden' value='0' />"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_fields_for_with_only_object
- _erbout = ''
+ @output_buffer = ''
fields_for(@post) do |f|
- _erbout.concat f.text_field(:title)
- _erbout.concat f.text_area(:body)
- _erbout.concat f.check_box(:secret)
+ @output_buffer.concat f.text_field(:title)
+ @output_buffer.concat f.text_area(:body)
+ @output_buffer.concat f.check_box(:secret)
end
expected =
@@ -561,31 +561,31 @@ class FormHelperTest < ActionView::TestCase
"<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
"<input name='post[secret]' type='hidden' value='0' />"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_fields_for_object_with_bracketed_name
- _erbout = ''
+ @output_buffer = ''
fields_for("author[post]", @post) do |f|
- _erbout.concat f.label(:title)
- _erbout.concat f.text_field(:title)
+ @output_buffer.concat f.label(:title)
+ @output_buffer.concat f.text_field(:title)
end
assert_dom_equal "<label for=\"author_post_title\">Title</label>" +
"<input name='author[post][title]' size='30' type='text' id='author_post_title' value='Hello World' />",
- _erbout
+ @output_buffer
end
def test_fields_for_object_with_bracketed_name_and_index
- _erbout = ''
+ @output_buffer = ''
fields_for("author[post]", @post, :index => 1) do |f|
- _erbout.concat f.label(:title)
- _erbout.concat f.text_field(:title)
+ @output_buffer.concat f.label(:title)
+ @output_buffer.concat f.text_field(:title)
end
assert_dom_equal "<label for=\"author_post_1_title\">Title</label>" +
"<input name='author[post][1][title]' size='30' type='text' id='author_post_1_title' value='Hello World' />",
- _erbout
+ @output_buffer
end
def test_form_builder_does_not_have_form_for_method
@@ -593,14 +593,14 @@ class FormHelperTest < ActionView::TestCase
end
def test_form_for_and_fields_for
- _erbout = ''
+ @output_buffer = ''
form_for(:post, @post, :html => { :id => 'create-post' }) do |post_form|
- _erbout.concat post_form.text_field(:title)
- _erbout.concat post_form.text_area(:body)
+ @output_buffer.concat post_form.text_field(:title)
+ @output_buffer.concat post_form.text_area(:body)
fields_for(:parent_post, @post) do |parent_fields|
- _erbout.concat parent_fields.check_box(:secret)
+ @output_buffer.concat parent_fields.check_box(:secret)
end
end
@@ -612,18 +612,18 @@ class FormHelperTest < ActionView::TestCase
"<input name='parent_post[secret]' type='hidden' value='0' />" +
"</form>"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_form_for_and_fields_for_with_object
- _erbout = ''
+ @output_buffer = ''
form_for(:post, @post, :html => { :id => 'create-post' }) do |post_form|
- _erbout.concat post_form.text_field(:title)
- _erbout.concat post_form.text_area(:body)
+ @output_buffer.concat post_form.text_field(:title)
+ @output_buffer.concat post_form.text_area(:body)
post_form.fields_for(@comment) do |comment_fields|
- _erbout.concat comment_fields.text_field(:name)
+ @output_buffer.concat comment_fields.text_field(:name)
end
end
@@ -634,7 +634,7 @@ class FormHelperTest < ActionView::TestCase
"<input name='post[comment][name]' type='text' id='post_comment_name' value='new comment' size='30' />" +
"</form>"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
class LabelledFormBuilder < ActionView::Helpers::FormBuilder
@@ -649,12 +649,12 @@ class FormHelperTest < ActionView::TestCase
end
def test_form_for_with_labelled_builder
- _erbout = ''
+ @output_buffer = ''
form_for(:post, @post, :builder => LabelledFormBuilder) do |f|
- _erbout.concat f.text_field(:title)
- _erbout.concat f.text_area(:body)
- _erbout.concat f.check_box(:secret)
+ @output_buffer.concat f.text_field(:title)
+ @output_buffer.concat f.text_area(:body)
+ @output_buffer.concat f.check_box(:secret)
end
expected =
@@ -665,18 +665,18 @@ class FormHelperTest < ActionView::TestCase
"<input name='post[secret]' type='hidden' value='0' /><br/>" +
"</form>"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_default_form_builder
old_default_form_builder, ActionView::Base.default_form_builder =
ActionView::Base.default_form_builder, LabelledFormBuilder
- _erbout = ''
+ @output_buffer = ''
form_for(:post, @post) do |f|
- _erbout.concat f.text_field(:title)
- _erbout.concat f.text_area(:body)
- _erbout.concat f.check_box(:secret)
+ @output_buffer.concat f.text_field(:title)
+ @output_buffer.concat f.text_area(:body)
+ @output_buffer.concat f.check_box(:secret)
end
expected =
@@ -687,17 +687,17 @@ class FormHelperTest < ActionView::TestCase
"<input name='post[secret]' type='hidden' value='0' /><br/>" +
"</form>"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
ensure
ActionView::Base.default_form_builder = old_default_form_builder
end
def test_default_form_builder_with_active_record_helpers
- _erbout = ''
+ @output_buffer = ''
form_for(:post, @post) do |f|
- _erbout.concat f.error_message_on('author_name')
- _erbout.concat f.error_messages
+ @output_buffer.concat f.error_message_on('author_name')
+ @output_buffer.concat f.error_messages
end
expected = %(<form action='http://www.example.com' method='post'>) +
@@ -705,7 +705,7 @@ class FormHelperTest < ActionView::TestCase
%(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>) +
%(</form>)
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
@@ -713,10 +713,10 @@ class FormHelperTest < ActionView::TestCase
post = @post
@post = nil
- _erbout = ''
+ @output_buffer = ''
form_for(:post, post) do |f|
- _erbout.concat f.error_message_on('author_name')
- _erbout.concat f.error_messages
+ @output_buffer.concat f.error_message_on('author_name')
+ @output_buffer.concat f.error_messages
end
expected = %(<form action='http://www.example.com' method='post'>) +
@@ -724,19 +724,19 @@ class FormHelperTest < ActionView::TestCase
%(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>) +
%(</form>)
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
# Perhaps this test should be moved to prototype helper tests.
def test_remote_form_for_with_labelled_builder
self.extend ActionView::Helpers::PrototypeHelper
- _erbout = ''
+ @output_buffer = ''
remote_form_for(:post, @post, :builder => LabelledFormBuilder) do |f|
- _erbout.concat f.text_field(:title)
- _erbout.concat f.text_area(:body)
- _erbout.concat f.check_box(:secret)
+ @output_buffer.concat f.text_field(:title)
+ @output_buffer.concat f.text_area(:body)
+ @output_buffer.concat f.check_box(:secret)
end
expected =
@@ -747,16 +747,16 @@ class FormHelperTest < ActionView::TestCase
"<input name='post[secret]' type='hidden' value='0' /><br/>" +
"</form>"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_fields_for_with_labelled_builder
- _erbout = ''
+ @output_buffer = ''
fields_for(:post, @post, :builder => LabelledFormBuilder) do |f|
- _erbout.concat f.text_field(:title)
- _erbout.concat f.text_area(:body)
- _erbout.concat f.check_box(:secret)
+ @output_buffer.concat f.text_field(:title)
+ @output_buffer.concat f.text_area(:body)
+ @output_buffer.concat f.check_box(:secret)
end
expected =
@@ -765,28 +765,28 @@ class FormHelperTest < ActionView::TestCase
"<label for='secret'>Secret:</label> <input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
"<input name='post[secret]' type='hidden' value='0' /><br/>"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_form_for_with_html_options_adds_options_to_form_tag
- _erbout = ''
+ @output_buffer = ''
form_for(:post, @post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end
expected = "<form action=\"http://www.example.com\" class=\"some_class\" id=\"some_form\" method=\"post\"></form>"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_form_for_with_string_url_option
- _erbout = ''
+ @output_buffer = ''
form_for(:post, @post, :url => 'http://www.otherdomain.com') do |f| end
- assert_equal '<form action="http://www.otherdomain.com" method="post"></form>', _erbout
+ assert_equal '<form action="http://www.otherdomain.com" method="post"></form>', @output_buffer
end
def test_form_for_with_hash_url_option
- _erbout = ''
+ @output_buffer = ''
form_for(:post, @post, :url => {:controller => 'controller', :action => 'action'}) do |f| end
@@ -795,25 +795,25 @@ class FormHelperTest < ActionView::TestCase
end
def test_form_for_with_record_url_option
- _erbout = ''
+ @output_buffer = ''
form_for(:post, @post, :url => @post) do |f| end
expected = "<form action=\"/posts/123\" method=\"post\"></form>"
- assert_equal expected, _erbout
+ assert_equal expected, @output_buffer
end
def test_form_for_with_existing_object
- _erbout = ''
+ @output_buffer = ''
form_for(@post) do |f| end
expected = "<form action=\"/posts/123\" class=\"edit_post\" id=\"edit_post_123\" method=\"post\"><div style=\"margin:0;padding:0\"><input name=\"_method\" type=\"hidden\" value=\"put\" /></div></form>"
- assert_equal expected, _erbout
+ assert_equal expected, @output_buffer
end
def test_form_for_with_new_object
- _erbout = ''
+ @output_buffer = ''
post = Post.new
post.new_record = true
@@ -822,64 +822,64 @@ class FormHelperTest < ActionView::TestCase
form_for(post) do |f| end
expected = "<form action=\"/posts\" class=\"new_post\" id=\"new_post\" method=\"post\"></form>"
- assert_equal expected, _erbout
+ assert_equal expected, @output_buffer
end
def test_form_for_with_existing_object_in_list
@post.new_record = false
@comment.save
- _erbout = ''
+ @output_buffer = ''
form_for([@post, @comment]) {}
expected = %(<form action="#{comment_path(@post, @comment)}" class="edit_comment" id="edit_comment_1" method="post"><div style="margin:0;padding:0"><input name="_method" type="hidden" value="put" /></div></form>)
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_form_for_with_new_object_in_list
@post.new_record = false
- _erbout = ''
+ @output_buffer = ''
form_for([@post, @comment]) {}
expected = %(<form action="#{comments_path(@post)}" class="new_comment" id="new_comment" method="post"></form>)
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_form_for_with_existing_object_and_namespace_in_list
@post.new_record = false
@comment.save
- _erbout = ''
+ @output_buffer = ''
form_for([:admin, @post, @comment]) {}
expected = %(<form action="#{admin_comment_path(@post, @comment)}" class="edit_comment" id="edit_comment_1" method="post"><div style="margin:0;padding:0"><input name="_method" type="hidden" value="put" /></div></form>)
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_form_for_with_new_object_and_namespace_in_list
@post.new_record = false
- _erbout = ''
+ @output_buffer = ''
form_for([:admin, @post, @comment]) {}
expected = %(<form action="#{admin_comments_path(@post)}" class="new_comment" id="new_comment" method="post"></form>)
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end
def test_form_for_with_existing_object_and_custom_url
- _erbout = ''
+ @output_buffer = ''
form_for(@post, :url => "/super_posts") do |f| end
expected = "<form action=\"/super_posts\" class=\"edit_post\" id=\"edit_post_123\" method=\"post\"><div style=\"margin:0;padding:0\"><input name=\"_method\" type=\"hidden\" value=\"put\" /></div></form>"
- assert_equal expected, _erbout
+ assert_equal expected, @output_buffer
end
def test_remote_form_for_with_html_options_adds_options_to_form_tag
self.extend ActionView::Helpers::PrototypeHelper
- _erbout = ''
+ @output_buffer = ''
remote_form_for(:post, @post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end
expected = "<form action=\"http://www.example.com\" class=\"some_class\" id=\"some_form\" method=\"post\" onsubmit=\"new Ajax.Request('http://www.example.com', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\"></form>"
- assert_dom_equal expected, _erbout
+ assert_dom_equal expected, @output_buffer
end