aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/base_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2004-12-01 13:18:51 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2004-12-01 13:18:51 +0000
commit0daa29ece29191b288fe86d3616bea0357325419 (patch)
tree7a86e47e5b7c68467c1ef01e08be0ac24faf29a9 /activerecord/test/base_test.rb
parent50f333b203756009acff2457b6d1c9da3b532cad (diff)
downloadrails-0daa29ece29191b288fe86d3616bea0357325419.tar.gz
rails-0daa29ece29191b288fe86d3616bea0357325419.tar.bz2
rails-0daa29ece29191b288fe86d3616bea0357325419.zip
Added proper handling of time fields that are turned into Time objects with the dummy date of 2000/1/1 [HariSeldon]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@40 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/base_test.rb')
-rwxr-xr-xactiverecord/test/base_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb
index 0d2278eb58..c362fd7139 100755
--- a/activerecord/test/base_test.rb
+++ b/activerecord/test/base_test.rb
@@ -147,6 +147,11 @@ class BasicsTest < Test::Unit::TestCase
Date, Topic.find(1).last_read,
"The last_read attribute should be of the Date class"
)
+
+ assert_kind_of(
+ Time, Topic.find(1).bonus_time,
+ "The bonus_time attribute should be of the Time class"
+ )
end
def test_preserving_time_objects
@@ -311,6 +316,7 @@ class BasicsTest < Test::Unit::TestCase
topic = Topic.new
assert_equal 1, topic.approved
assert_nil topic.written_on
+ assert_nil topic.bonus_time
assert_nil topic.last_read
topic.save
@@ -426,6 +432,15 @@ class BasicsTest < Test::Unit::TestCase
assert_equal Time.local(2004, 6, 24, 16, 24, 0), topic.written_on
end
+ def test_attributes_on_dummy_time
+ attributes = {
+ "bonus_time" => "5:42:00AM"
+ }
+ topic = Topic.find(1)
+ topic.attributes = attributes
+ assert_equal Time.local(2000, 1, 1, 5, 42, 0), topic.bonus_time
+ end
+
def test_boolean
b_false = Booleantest.create({ "value" => false })
false_id = b_false.id