1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add test case for average on the interval column

This commit is contained in:
Ryuta Kamizono 2021-02-13 14:46:01 +09:00
parent 7f05d8c2af
commit 1a60826c9d

View file

@ -86,6 +86,14 @@ class PostgresqlIntervalTest < ActiveRecord::PostgreSQLTestCase
assert_equal "P1DT1H", i.legacy_term
end
def test_average_interval_type
IntervalDataType.create!([{ maximum_term: 6.years }, { maximum_term: 4.months }])
value = IntervalDataType.average(:maximum_term)
assert_equal 3.years + 2.months, value
assert_instance_of ActiveSupport::Duration, value
end
def test_deprecated_legacy_type
assert_deprecated do
DeprecatedIntervalDataType.new