aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-06-12 01:03:10 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-06-16 08:04:16 +0900
commit10b81fb51acc600926613e9ea78125635950a1f0 (patch)
tree0c3877333d41686d8ffc04a72d4dd75c0cf45e57 /activerecord
parent7980b31bc6dd123a0635f470998362a602b66e25 (diff)
downloadrails-10b81fb51acc600926613e9ea78125635950a1f0.tar.gz
rails-10b81fb51acc600926613e9ea78125635950a1f0.tar.bz2
rails-10b81fb51acc600926613e9ea78125635950a1f0.zip
Fix `Type::Date#serialize` to return a date object correctly
Currently `Type::Date#serialize` does not cast a value to a date object. It should be cast to a date object for finding by date column correctly working. Fixes #25354.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/date_test.rb (renamed from activerecord/test/cases/invalid_date_test.rb)14
1 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/test/cases/invalid_date_test.rb b/activerecord/test/cases/date_test.rb
index 426a350379..f112081c14 100644
--- a/activerecord/test/cases/invalid_date_test.rb
+++ b/activerecord/test/cases/date_test.rb
@@ -1,7 +1,19 @@
require 'cases/helper'
require 'models/topic'
-class InvalidDateTest < ActiveRecord::TestCase
+class DateTest < ActiveRecord::TestCase
+ def test_date_with_time_value
+ time_value = Time.new(2016, 05, 11, 19, 0, 0)
+ topic = Topic.create(last_read: time_value)
+ assert_equal topic, Topic.find_by(last_read: time_value)
+ end
+
+ def test_date_with_string_value
+ string_value = '2016-05-11 19:00:00'
+ topic = Topic.create(last_read: string_value)
+ assert_equal topic, Topic.find_by(last_read: string_value)
+ end
+
def test_assign_valid_dates
valid_dates = [[2007, 11, 30], [1993, 2, 28], [2008, 2, 29]]