mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-02 23:38:50 +01:00
fix failing test on timezones and remove debug message
This commit is contained in:
parent
cb46a8461e
commit
fee1e3b504
4 changed files with 6 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue