test/test_helper.rb in groupdate-2.0.1 vs test/test_helper.rb in groupdate-2.0.2

- old
+ new

@@ -478,10 +478,21 @@ create_user "2013-05-01 00:00:00 UTC" time_zone = "Pacific Time (US & Canada)" assert_equal time_zone, User.group_by_day(:created_at, time_zone: time_zone).count.keys.first.time_zone.name end + def test_where_after + create_user "2013-05-01 00:00:00 UTC" + create_user "2013-05-02 00:00:00 UTC" + expected = {utc.parse("2013-05-02 00:00:00 UTC") => 1} + assert_equal expected, User.group_by_day(:created_at).where("created_at > ?", "2013-05-01 00:00:00 UTC").count + end + + def test_bad_method + assert_raises(NoMethodError) { User.group_by_day(:created_at).no_such_method } + end + # helpers def assert_result_time(method, expected, time_str, time_zone = false, options = {}) assert_result method, Time.parse(expected), time_str, time_zone, options end @@ -505,10 +516,14 @@ def ordered_hash(hash) RUBY_VERSION =~ /1\.8/ ? hash.inject(ActiveSupport::OrderedHash.new){|h, (k, v)| h[k] = v; h } : hash end def create_user(created_at) - User.create! :name => "Andrew", :score => 1, :created_at => ActiveSupport::TimeZone["UTC"].parse(created_at) + User.create! :name => "Andrew", :score => 1, :created_at => utc.parse(created_at) + end + + def utc + ActiveSupport::TimeZone["UTC"] end def teardown User.delete_all end