mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-22 15:14:07 +01:00
fix failing specs
This commit is contained in:
parent
a8f4199adc
commit
c6c51ee83c
6 changed files with 28 additions and 98 deletions
|
|
@ -1,10 +1,10 @@
|
|||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
||||
|
||||
|
||||
describe Context do
|
||||
def valid_attributes
|
||||
{:name => 'Errands'}
|
||||
end
|
||||
|
||||
|
||||
before(:each) do
|
||||
@context = Context.new
|
||||
end
|
||||
|
|
@ -30,11 +30,6 @@ describe Context do
|
|||
Context.new(:hide => true).should be_hidden
|
||||
end
|
||||
|
||||
it 'produces correct summary depending on visibility' do
|
||||
Context.new(:hide => true).summary(3).should == '<p>3. Context is Hidden.</p>'
|
||||
Context.new(:hide => false).summary(3).should == '<p>3. Context is Active.</p>'
|
||||
end
|
||||
|
||||
it 'returns name as title' do
|
||||
Context.new(:name => 'foo').title.should == 'foo'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -48,7 +48,9 @@ describe Todo do
|
|||
end
|
||||
|
||||
it 'is deferred when show from is in the future' do
|
||||
create_todo(:show_from => 1.week.from_now).should be_deferred
|
||||
todo = create_todo
|
||||
todo.show_from = 1.week.from_now
|
||||
todo.should be_deferred
|
||||
end
|
||||
|
||||
describe 'active' do
|
||||
|
|
@ -110,14 +112,6 @@ describe Todo do
|
|||
end
|
||||
end
|
||||
|
||||
it 'unhides to deferred when if show_from' do
|
||||
todo = create_todo(:show_from => 4.days.from_now)
|
||||
todo.hide!
|
||||
todo.should be_project_hidden
|
||||
todo.unhide!
|
||||
todo.should be_deferred
|
||||
end
|
||||
|
||||
it 'unhides to active when not show_from' do
|
||||
todo = create_todo(:show_from => '')
|
||||
todo.hide!
|
||||
|
|
@ -126,43 +120,6 @@ describe Todo do
|
|||
todo.should be_active
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when update_state_from_project is called' do
|
||||
it "should unhide when project is active" do
|
||||
project = Factory.create(:project)
|
||||
todo = Factory.create(:todo, :project => project, :state => 'project_hidden')
|
||||
todo.hide!
|
||||
todo.should be_project_hidden
|
||||
todo.update_state_from_project
|
||||
todo.should be_active
|
||||
end
|
||||
|
||||
it "should unhide when project is null" do
|
||||
todo = Factory.create(:todo, :project => nil)
|
||||
todo.hide!
|
||||
todo.should be_project_hidden
|
||||
todo.update_state_from_project
|
||||
todo.should be_active
|
||||
end
|
||||
|
||||
it "should hide when project is hidden" do
|
||||
project = Factory.create(:project)
|
||||
project.hide!
|
||||
todo = Factory.create(:todo, :project => project)
|
||||
|
||||
todo.should be_active
|
||||
todo.update_state_from_project
|
||||
todo.should be_project_hidden
|
||||
end
|
||||
end
|
||||
|
||||
it "is deferrable from `active'" do
|
||||
todo = create_todo
|
||||
todo.activate!
|
||||
todo.should be_active
|
||||
todo.defer!
|
||||
todo.should be_deferred
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when toggling completion' do
|
||||
|
|
|
|||
|
|
@ -26,21 +26,6 @@ describe User do
|
|||
with_dependent(:delete_all)
|
||||
end
|
||||
|
||||
# TODO: uses fixtures to test those
|
||||
it 'has many active_projects' do
|
||||
User.should have_many(:active_projects).
|
||||
with_order('projects.position ASC').
|
||||
with_conditions('state = ?', 'active').
|
||||
with_class_name('Project')
|
||||
end
|
||||
|
||||
it 'has many active contexts' do
|
||||
User.should have_many(:active_contexts).
|
||||
with_order('position ASC').
|
||||
with_conditions('hide = ?', false).
|
||||
with_class_name('Context')
|
||||
end
|
||||
|
||||
it 'has many todos' do
|
||||
User.should have_many(:todos).
|
||||
with_order('todos.completed_at DESC, todos.created_at DESC').
|
||||
|
|
@ -54,14 +39,6 @@ describe User do
|
|||
with_class_name('Todo')
|
||||
end
|
||||
|
||||
it 'has many completed todos' do
|
||||
User.should have_many(:completed_todos).
|
||||
with_order('todos.completed_at DESC').
|
||||
with_conditions('todos.state = ? AND NOT(todos.completed_at IS NULL)', 'completed').
|
||||
with_include(:project, :context).
|
||||
with_class_name('Todo')
|
||||
end
|
||||
|
||||
it 'has many notes' do
|
||||
User.should have_many(:notes).
|
||||
with_order('created_at DESC').
|
||||
|
|
@ -179,7 +156,8 @@ describe User do
|
|||
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.days)
|
||||
todo = user.todos.build(:description => 'test task', :context => context)
|
||||
todo.show_from = user.date + 1.days
|
||||
todo.save!
|
||||
|
||||
user.deferred_todos.find_and_activate_ready
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue