Merge branch 'timezones' of git://github.com/epall/tracks into timezones

This commit is contained in:
Reinier Balt 2008-09-10 09:59:36 +02:00
commit 262b976c45
2 changed files with 16 additions and 2 deletions

View file

@ -71,8 +71,7 @@ class User < ActiveRecord::Base
:conditions => [ 'state = ?', 'deferred' ],
:order => 'show_from ASC, todos.created_at DESC' do
def find_and_activate_ready
# assumes that active record uses :utc to store datetime in db
find(:all, :conditions => ['show_from <= ?', Time.now.utc ]).collect { |t| t.activate! }
find(:all, :conditions => ['show_from <= ?', proxy_owner.date ]).collect { |t| t.activate! }
end
end
has_many :completed_todos,

View file

@ -178,4 +178,19 @@ describe User do
@user.remember_token_expires_at.should be_between(before, after)
end
end
it "should not activate todos that are showing when UTC is tomorrow" do
context = Context.create(:name => 'a context')
user = User.create(:login => 'user7', :password => 'foobar', :password_confirmation => 'foobar')
user.save!
user.create_preference
user.preference.update_attribute('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.save!
user.deferred_todos.find_and_activate_ready
user = User.find(user.id)
user.deferred_todos.should include(todo)
end
end