test/test_helper.rb in groupdate-1.0.4 vs test/test_helper.rb in groupdate-1.0.5

- old
+ new

@@ -318,10 +318,21 @@ user = User.create!(name: "Andrew") user.update_column :created_at, nil assert_equal 0, User.group_by_hour_of_day(:created_at, Time.zone, true).count[0] end + def test_zeroes_range_true + create_user "2013-05-01 00:00:00 UTC" + create_user "2013-05-03 00:00:00 UTC" + expected = { + Time.parse("2013-05-01 00:00:00 UTC") => 1, + Time.parse("2013-05-02 00:00:00 UTC") => 0, + Time.parse("2013-05-03 00:00:00 UTC") => 1 + } + assert_equal expected, User.group_by_day(:created_at, Time.zone, true).count + end + # week_start def test_week_start Groupdate.week_start = :mon assert_result_time :week, "2013-03-18 00:00:00 UTC", "2013-03-24 23:59:59" @@ -363,9 +374,10 @@ def assert_result(method, expected, time_str, time_zone = false, options = {}) create_user time_str expected = expected.is_a?(Time) ? time_key(expected) : number_key(expected) assert_equal ordered_hash({expected => 1}), User.send(:"group_by_#{method}", :created_at, time_zone ? "Pacific Time (US & Canada)" : nil, options).order(method.to_s).count + assert_equal 1, User.send(:"group_by_#{method}", :created_at, time_zone ? "Pacific Time (US & Canada)" : nil, true, options).count[expected] end def assert_zeros(method, created_at, keys, range_start, range_end, time_zone = nil, options = {}) create_user created_at expected = {}