Commit 74e7204b53c215838e07283b10675520cb6e3d47
1 parent
871837df
Exists in
master
and in
17 other branches
Prettier tests
Showing
1 changed file
with
13 additions
and
13 deletions
Show diff stats
test/test_helper.rb
... | ... | @@ -269,7 +269,7 @@ module TestGroupdate |
269 | 269 | 7.times do |n| |
270 | 270 | expected[n] = n == 3 ? 1 : 0 |
271 | 271 | end |
272 | - assert_equal(expected, User.group_by_day_of_week(:created_at, Time.zone, true).count(:created_at)) | |
272 | + assert_equal expected, User.group_by_day_of_week(:created_at, Time.zone, true).count(:created_at) | |
273 | 273 | end |
274 | 274 | |
275 | 275 | def test_zeros_hour_of_day |
... | ... | @@ -278,7 +278,7 @@ module TestGroupdate |
278 | 278 | 24.times do |n| |
279 | 279 | expected[n] = n == 20 ? 1 : 0 |
280 | 280 | end |
281 | - assert_equal(expected, User.group_by_hour_of_day(:created_at, Time.zone, true).count(:created_at)) | |
281 | + assert_equal expected, User.group_by_hour_of_day(:created_at, Time.zone, true).count(:created_at) | |
282 | 282 | end |
283 | 283 | |
284 | 284 | def test_zeros_excludes_end |
... | ... | @@ -286,7 +286,7 @@ module TestGroupdate |
286 | 286 | expected = { |
287 | 287 | Time.parse("2013-05-01 00:00:00 UTC") => 0 |
288 | 288 | } |
289 | - assert_equal(expected, User.group_by_day(:created_at, Time.zone, Time.parse("2013-05-01 00:00:00 UTC")...Time.parse("2013-05-02 00:00:00 UTC")).count) | |
289 | + assert_equal expected, User.group_by_day(:created_at, Time.zone, Time.parse("2013-05-01 00:00:00 UTC")...Time.parse("2013-05-02 00:00:00 UTC")).count | |
290 | 290 | end |
291 | 291 | |
292 | 292 | def test_zeros_previous_scope |
... | ... | @@ -294,7 +294,7 @@ module TestGroupdate |
294 | 294 | expected = { |
295 | 295 | Time.parse("2013-05-01 00:00:00 UTC") => 0 |
296 | 296 | } |
297 | - assert_equal(expected, User.where("id = 0").group_by_day(:created_at, Time.zone, Time.parse("2013-05-01 00:00:00 UTC")..Time.parse("2013-05-01 23:59:59 UTC")).count) | |
297 | + assert_equal expected, User.where("id = 0").group_by_day(:created_at, Time.zone, Time.parse("2013-05-01 00:00:00 UTC")..Time.parse("2013-05-01 23:59:59 UTC")).count | |
298 | 298 | end |
299 | 299 | |
300 | 300 | def test_zeros_datetime |
... | ... | @@ -302,7 +302,7 @@ module TestGroupdate |
302 | 302 | expected = { |
303 | 303 | Time.parse("2013-05-01 00:00:00 UTC") => 1 |
304 | 304 | } |
305 | - assert_equal(expected, User.group_by_day(:created_at, Time.zone, DateTime.parse("2013-05-01 00:00:00 UTC")..DateTime.parse("2013-05-01 00:00:00 UTC")).count) | |
305 | + assert_equal expected, User.group_by_day(:created_at, Time.zone, DateTime.parse("2013-05-01 00:00:00 UTC")..DateTime.parse("2013-05-01 00:00:00 UTC")).count | |
306 | 306 | end |
307 | 307 | |
308 | 308 | def test_zeros_null_value |
... | ... | @@ -314,24 +314,24 @@ module TestGroupdate |
314 | 314 | # misc |
315 | 315 | |
316 | 316 | def test_order_day |
317 | - assert_equal({}, User.group_by_day(:created_at).order("day desc").limit(20).count) | |
317 | + assert_empty User.group_by_day(:created_at).order("day desc").limit(20).count | |
318 | 318 | end |
319 | 319 | |
320 | 320 | def test_order_week |
321 | - assert_equal({}, User.group_by_week(:created_at).order("week asc").count) | |
321 | + assert_empty User.group_by_week(:created_at).order("week asc").count | |
322 | 322 | end |
323 | 323 | |
324 | 324 | def test_order_hour_of_day |
325 | - assert_equal({}, User.group_by_hour_of_day(:created_at).order("hour_of_day desc").count) | |
325 | + assert_empty User.group_by_hour_of_day(:created_at).order("hour_of_day desc").count | |
326 | 326 | end |
327 | 327 | |
328 | 328 | def test_table_name |
329 | - assert_equal({}, User.group_by_day("users.created_at").count) | |
329 | + assert_empty User.group_by_day("users.created_at").count | |
330 | 330 | end |
331 | 331 | |
332 | 332 | def test_previous_scopes |
333 | 333 | create_user "2013-05-01 00:00:00 UTC" |
334 | - assert_equal({}, User.where("id = 0").group_by_day(:created_at).count) | |
334 | + assert_empty User.where("id = 0").group_by_day(:created_at).count | |
335 | 335 | end |
336 | 336 | |
337 | 337 | # helpers |
... | ... | @@ -343,7 +343,7 @@ module TestGroupdate |
343 | 343 | def assert_result(method, expected, time_str, time_zone = false, options = {}) |
344 | 344 | create_user time_str |
345 | 345 | expected = expected.is_a?(Time) ? time_key(expected) : number_key(expected) |
346 | - 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) | |
346 | + 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 | |
347 | 347 | end |
348 | 348 | |
349 | 349 | def assert_zeros(method, created_at, keys, range_start, range_end, time_zone = nil, options = {}) |
... | ... | @@ -352,7 +352,7 @@ module TestGroupdate |
352 | 352 | keys.each_with_index do |key, i| |
353 | 353 | expected[Time.parse(key)] = i == 1 ? 1 : 0 |
354 | 354 | end |
355 | - assert_equal(expected, User.send(:"group_by_#{method}", :created_at, time_zone ? "Pacific Time (US & Canada)" : nil, Time.parse(range_start)..Time.parse(range_end), options).count) | |
355 | + assert_equal expected, User.send(:"group_by_#{method}", :created_at, time_zone ? "Pacific Time (US & Canada)" : nil, Time.parse(range_start)..Time.parse(range_end), options).count | |
356 | 356 | end |
357 | 357 | |
358 | 358 | def ordered_hash(hash) |
... | ... | @@ -360,7 +360,7 @@ module TestGroupdate |
360 | 360 | end |
361 | 361 | |
362 | 362 | def create_user(created_at) |
363 | - User.create!(:name => "Andrew", :score => 1, :created_at => ActiveSupport::TimeZone["UTC"].parse(created_at)) | |
363 | + User.create! :name => "Andrew", :score => 1, :created_at => ActiveSupport::TimeZone["UTC"].parse(created_at) | |
364 | 364 | end |
365 | 365 | |
366 | 366 | def teardown | ... | ... |