fix failing test on timezones and remove debug message

This commit is contained in:
Reinier Balt 2013-09-05 12:23:26 +02:00
parent cb46a8461e
commit fee1e3b504
4 changed files with 6 additions and 5 deletions

View file

@ -48,7 +48,6 @@ class RecurringTodo < ActiveRecord::Base
end
def validate_weekly
puts "@@@ validate_weekly [#{self.weekly_every_x_week}]"
if weekly_every_x_week.blank?
errors[:base] << "Every other nth week may not be empty for recurrence setting"
end

View file

@ -2,9 +2,10 @@ require 'active_support/all'
class Staleness
SECONDS_PER_DAY = 86400
def self.days_stale(item, current_user)
return 0 if cannot_be_stale(item, current_user)
(UserTime.new(current_user).time - item.created_at).to_i / SECONDS_PER_DAY
(UserTime.new(current_user).time.utc - item.created_at.utc).to_i / SECONDS_PER_DAY
end
def self.cannot_be_stale(item, current_user)

View file

@ -20,7 +20,7 @@ class PreferenceTest < ActiveSupport::TestCase
end
def test_parse_date
date = Time.new(2007, 05, 20).in_time_zone(@admin_user.preference.time_zone).at_midnight
date = UserTime.new(@admin_user).midnight(Time.new(2007, 05, 20, 0, 0, 0))
assert_equal date.to_s, @admin_user.preference.parse_date('20/5/2007').to_s
end

View file

@ -1,6 +1,7 @@
require_relative '../minimal_test_helper'
require_relative '../../lib/staleness'
require_relative '../../lib/user_time'
require 'timecop'
class StalenessTest < Test::Unit::TestCase
FakePrefs = Struct.new(:time_zone)
@ -35,7 +36,7 @@ class StalenessTest < Test::Unit::TestCase
def setup
@current_user = FakeUser.new(now)
Timecop.freeze(Time.local(2013,02,28))
Timecop.freeze(Time.utc(2013,02,28))
end
def teardown