Commit 3181c9a665b737a11d6dcaa63fcdfb629fe138ef

Authored by Andrew Kane
1 parent 672569b9

Fixed tests [skip ci]

Showing 1 changed file with 12 additions and 7 deletions   Show diff stats
test/test_helper.rb
... ... @@ -227,10 +227,13 @@ module TestDatabase
227 227  
228 228 def test_last_date
229 229 Time.zone = pt
230   - create_user Date.today.to_s
  230 + today = Date.today
  231 + create_user today.to_s
  232 + this_month = today.in_time_zone(pt).beginning_of_month
  233 + last_month = this_month - 1.month
231 234 expected = {
232   - Date.parse("#{this_year}-#{this_month - 1}-01") => 0,
233   - Date.parse("#{this_year}-#{this_month}-01") => 1
  235 + last_month.to_date => 0,
  236 + this_month.to_date => 1
234 237 }
235 238 assert_equal expected, User.group_by_month(:created_on, last: 2).count
236 239 ensure
... ... @@ -253,11 +256,13 @@ module TestDatabase
253 256 end
254 257  
255 258 def test_quarter_and_last
256   - create_user "#{this_year}-#{this_quarters_month}-01"
257   - create_user "#{this_year}-#{this_quarters_month - 6}-01"
  259 + today = Date.today
  260 + create_user today.to_s
  261 + this_quarter = today.to_time.beginning_of_quarter
  262 + last_quarter = this_quarter - 3.months
258 263 expected = {
259   - Date.parse("#{this_year}-#{this_quarters_month - 3}-01") => 0,
260   - Date.parse("#{this_year}-#{this_quarters_month}-01") => 1
  264 + last_quarter.to_date => 0,
  265 + this_quarter.to_date => 1
261 266 }
262 267 assert_equal expected, User.group_by_quarter(:created_at, last: 2).count
263 268 end
... ...