mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-26 10:46:10 +01:00
A few fixes after more thorough review.
This commit is contained in:
parent
778427405a
commit
f52a2eafa8
7 changed files with 13 additions and 13 deletions
|
|
@ -173,7 +173,7 @@ class ApplicationController < ActionController::Base
|
|||
if show_from_date.nil?
|
||||
todo.show_from=nil
|
||||
else
|
||||
todo.show_from = show_from_date.to_time < Time.now.utc ? nil : show_from_date
|
||||
todo.show_from = show_from_date < Time.now.utc ? nil : show_from_date
|
||||
end
|
||||
|
||||
saved = todo.save
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class Preference < ActiveRecord::Base
|
|||
|
||||
def parse_date(s)
|
||||
return nil if s.blank?
|
||||
Date.strptime(s, date_format)
|
||||
user.at_midnight(Date.strptime(s, date_format))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -71,7 +71,7 @@ class User < ActiveRecord::Base
|
|||
:conditions => [ 'state = ?', 'deferred' ],
|
||||
:order => 'show_from ASC, todos.created_at DESC' do
|
||||
def find_and_activate_ready
|
||||
find(:all, :conditions => ['show_from <= ?', proxy_owner.date ]).collect { |t| t.activate! }
|
||||
find(:all, :conditions => ['show_from <= ?', Time.now ]).collect { |t| t.activate! }
|
||||
end
|
||||
end
|
||||
has_many :completed_todos,
|
||||
|
|
|
|||
|
|
@ -4,17 +4,16 @@ class ChangeDatesToDatetimes < ActiveRecord::Migration
|
|||
change_column :todos, :due, :datetime
|
||||
change_column :recurring_todos, :start_from, :datetime
|
||||
change_column :recurring_todos, :end_date, :datetime
|
||||
|
||||
|
||||
User.all(:include => [:todos, :recurring_todos]).each do |user|
|
||||
zone = TimeZone[user.prefs.time_zone]
|
||||
user.todos.each do |todo|
|
||||
todo.update_attribute(:show_from, user.at_midnight(todo.show_from)) unless d.nil?
|
||||
todo.update_attribute(:due, user.at_midnight(todo.due)) unless d.nil?
|
||||
todo.update_attribute(:show_from, user.at_midnight(todo.show_from)) unless todo.show_from.nil?
|
||||
todo.update_attribute(:due, user.at_midnight(todo.due)) unless todo.due.nil?
|
||||
end
|
||||
|
||||
|
||||
user.recurring_todos.each do |todo|
|
||||
todo.update_attribute(:start_from, user.at_midnight(todo.start_from)) unless d.nil?
|
||||
todo.update_attribute(:end_date, user.at_midnight(todo.end_date)) unless d.nil?
|
||||
todo.update_attribute(:start_from, user.at_midnight(todo.start_from)) unless todo.start_from.nil?
|
||||
todo.update_attribute(:end_date, user.at_midnight(todo.end_date)) unless todo.end_date.nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -185,8 +185,9 @@ describe User do
|
|||
user.save!
|
||||
user.create_preference
|
||||
user.preference.update_attribute('time_zone', 'Pacific Time (US & Canada)')
|
||||
# Time.zone = 'Pacific Time (US & Canada)'
|
||||
Time.stub!(:now).and_return(Time.new.end_of_day - 20.minutes)
|
||||
todo = user.todos.build(:description => 'test task', :context => context, :show_from => user.date + 1)
|
||||
todo = user.todos.build(:description => 'test task', :context => context, :show_from => user.date + 1.days)
|
||||
todo.save!
|
||||
|
||||
user.deferred_todos.find_and_activate_ready
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class PreferenceTest < Test::Rails::TestCase
|
|||
end
|
||||
|
||||
def test_parse_date
|
||||
assert_equal Date.new(2007, 5, 20).to_s, @admin_user.preference.parse_date('20/5/2007').to_s
|
||||
assert_equal @admin_user.at_midnight(Date.new(2007, 5, 20)).to_s, @admin_user.preference.parse_date('20/5/2007').to_s
|
||||
end
|
||||
|
||||
def test_parse_date_returns_nil_if_string_is_empty
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ class UserTest < Test::Rails::TestCase
|
|||
|
||||
def test_find_and_activate_deferred_todos_that_are_ready
|
||||
assert_equal 1, @admin_user.deferred_todos.count
|
||||
@admin_user.deferred_todos[0].show_from = @admin_user.date
|
||||
@admin_user.deferred_todos[0].show_from = Time.now - 5.seconds
|
||||
@admin_user.deferred_todos[0].save
|
||||
@admin_user.deferred_todos.reload
|
||||
@admin_user.deferred_todos.find_and_activate_ready
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue