From 947cec29d5f074682052e8412904cc88a914fdbc Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 13 Nov 2005 11:13:11 +0000 Subject: Added FormHelper#form_for and FormHelper#fields_for that makes it easier to work with forms for single objects also if they don't reside in instance variables [DHH] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3003 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/template/date_helper_test.rb | 38 +++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'actionpack/test/template/date_helper_test.rb') diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb index a890baa115..bb6cd19013 100755 --- a/actionpack/test/template/date_helper_test.rb +++ b/actionpack/test/template/date_helper_test.rb @@ -1,9 +1,13 @@ require 'test/unit' -require File.dirname(__FILE__) + '/../../lib/action_view/helpers/date_helper' require File.dirname(__FILE__) + "/../abstract_unit" class DateHelperTest < Test::Unit::TestCase include ActionView::Helpers::DateHelper + include ActionView::Helpers::FormHelper + + silence_warnings do + Post = Struct.new("Post", :written_on, :updated_at) + end def test_distance_in_words from = Time.mktime(2004, 3, 6, 21, 41, 18) @@ -497,6 +501,38 @@ class DateHelperTest < Test::Unit::TestCase assert_equal expected, select_date(0, :start_year => 2003, :end_year => 2005, :prefix => "date[first]") end + def test_date_select_within_fields_for + @post = Post.new + @post.written_on = Date.new(2004, 6, 15) + + _erbout = '' + + fields_for :post => @post do |f| + _erbout.concat f.date_select(:written_on) + end + + expected = "\n" + + "\n" + + "\n" + + assert_dom_equal(expected, _erbout) + end + + def test_datetime_select_within_fields_for + @post = Post.new + @post.updated_at = Time.local(2004, 6, 15, 16, 35) + + _erbout = '' + + fields_for :post => @post do |f| + _erbout.concat f.datetime_select(:updated_at) + end + + expected = "\n\n\n — \n : \n" + + assert_dom_equal(expected, _erbout) + end + def test_date_select_with_zero_value_and_no_start_year expected = %(