mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-30 13:58:49 +01:00
fix failing specs
This commit is contained in:
parent
a8f4199adc
commit
c6c51ee83c
6 changed files with 28 additions and 98 deletions
|
|
@ -41,7 +41,7 @@ Feature: Tagging todos
|
|||
Then I should not see "prepare release" in the context container for "@pc"
|
||||
And I should see "prepare release" in the hidden container
|
||||
|
||||
@selenium @wip
|
||||
@selenium
|
||||
Scenario: I can move a tagged todo in tag view to a hidden context and it will move the todo on the page to the hidden container
|
||||
Given I have a hidden context called "@secret"
|
||||
When I go to the tag page for "tracks"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class TodosControllerTest < ActionController::TestCase
|
|||
assert_equal 3, assigns['context_not_done_counts'][contexts(:call).id]
|
||||
assert_equal 1, assigns['context_not_done_counts'][contexts(:lab).id]
|
||||
end
|
||||
|
||||
|
||||
def test_cached_not_done_counts_after_hiding_project
|
||||
p = Project.find(1)
|
||||
p.hide!
|
||||
|
|
@ -59,7 +59,7 @@ class TodosControllerTest < ActionController::TestCase
|
|||
assert_difference 'Todo.count' do
|
||||
put :create, :_source_view => 'todo', "context_name"=>"library", "project_name"=>"Build a working time machine", "todo"=>{
|
||||
"notes"=>"", "description"=>"test tags", "due"=>"30/11/2006"},
|
||||
"tag_list"=>"1234,5667,9876"
|
||||
"todo_tag_list"=>"1234,5667,9876"
|
||||
# default has_many_polymorphs will fail on these high numbers as tags with those id's do not exist
|
||||
end
|
||||
t = assigns['todo']
|
||||
|
|
@ -73,7 +73,7 @@ class TodosControllerTest < ActionController::TestCase
|
|||
assert_difference 'Todo.count' do
|
||||
put :create, :_source_view => 'todo', "context_name"=>"library", "project_name"=>"Build a working time machine", "todo"=>{
|
||||
"notes"=>"", "description"=>"test tags", "due"=>"30/11/2006"},
|
||||
"tag_list"=>"a,,b"
|
||||
"todo_tag_list"=>"a,,b"
|
||||
# default has_many_polymorphs will fail on the empty tag
|
||||
end
|
||||
t = assigns['todo']
|
||||
|
|
@ -138,7 +138,7 @@ class TodosControllerTest < ActionController::TestCase
|
|||
def test_fail_to_create_todo_via_xml
|
||||
login_as(:admin_user)
|
||||
# #try to create with no context, which is not valid
|
||||
put :create, :format => "xml", "request" => {
|
||||
put :create, :format => "xml", "request" => {
|
||||
"project_name"=>"Build a working time machine",
|
||||
"todo"=>{"notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"30/11/2006"}, "tag_list"=>"foo bar" }
|
||||
assert_response 422
|
||||
|
|
@ -550,7 +550,7 @@ class TodosControllerTest < ActionController::TestCase
|
|||
todo.reload()
|
||||
assert_equal "active", todo.state
|
||||
end
|
||||
|
||||
|
||||
def test_url_with_slash_in_query_string_are_parsed_correctly
|
||||
# See http://blog.swivel.com/code/2009/06/rails-auto_link-and-certain-query-strings.html
|
||||
login_as(:admin_user)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class TodoCreateParamsHelperTest < ActiveSupport::TestCase
|
|||
params_helper = TodosController::TodoCreateParamsHelper.new(params, prefs)
|
||||
assert_equal({'description' => 'foo'}, params_helper.attributes)
|
||||
end
|
||||
|
||||
|
||||
def test_show_from_accessor
|
||||
expected_date = Time.now
|
||||
params = { 'todo' => { 'show_from' => expected_date}}
|
||||
|
|
@ -24,7 +24,7 @@ class TodoCreateParamsHelperTest < ActiveSupport::TestCase
|
|||
params_helper = TodosController::TodoCreateParamsHelper.new(params, prefs)
|
||||
assert_equal(expected_date, params_helper.show_from)
|
||||
end
|
||||
|
||||
|
||||
def test_due_accessor
|
||||
expected_date = Time.now
|
||||
params = { 'todo' => { 'due' => expected_date}}
|
||||
|
|
@ -32,14 +32,14 @@ class TodoCreateParamsHelperTest < ActiveSupport::TestCase
|
|||
params_helper = TodosController::TodoCreateParamsHelper.new(params, prefs)
|
||||
assert_equal(expected_date, params_helper.due)
|
||||
end
|
||||
|
||||
|
||||
def test_tag_list_accessor
|
||||
params = { 'todo' => { }, 'tag_list' => 'foo, bar'}
|
||||
params = { 'todo' => { }, 'todo_tag_list' => 'foo, bar'}
|
||||
prefs = flexmock()
|
||||
params_helper = TodosController::TodoCreateParamsHelper.new(params, prefs)
|
||||
assert_equal('foo, bar', params_helper.tag_list)
|
||||
end
|
||||
|
||||
|
||||
def test_parse_dates_parses_show_from_date_based_on_prefs
|
||||
params = { 'todo' => { 'show_from' => '5/20/07', 'due' => '5/23/07'}}
|
||||
prefs = flexmock()
|
||||
|
|
@ -69,68 +69,68 @@ class TodoCreateParamsHelperTest < ActiveSupport::TestCase
|
|||
params_helper.parse_dates()
|
||||
assert_equal '', params_helper.due
|
||||
end
|
||||
|
||||
|
||||
def test_project_name_is_stripped_of_leading_and_trailing_whitespace
|
||||
params = { 'project_name' => ' Visit New Orleans ' }
|
||||
prefs = flexmock()
|
||||
params_helper = TodosController::TodoCreateParamsHelper.new(params, prefs)
|
||||
assert_equal 'Visit New Orleans', params_helper.project_name
|
||||
end
|
||||
|
||||
|
||||
def test_project_name_is_nil_when_unspecified
|
||||
params = { }
|
||||
prefs = flexmock()
|
||||
params_helper = TodosController::TodoCreateParamsHelper.new(params, prefs)
|
||||
assert_nil params_helper.project_name
|
||||
end
|
||||
|
||||
|
||||
def test_context_name_is_stripped_of_leading_and_trailing_whitespace
|
||||
params = { 'context_name' => ' mobile phone ' }
|
||||
prefs = flexmock()
|
||||
params_helper = TodosController::TodoCreateParamsHelper.new(params, prefs)
|
||||
assert_equal 'mobile phone', params_helper.context_name
|
||||
end
|
||||
|
||||
|
||||
def test_context_name_is_nil_when_unspecified
|
||||
params = { }
|
||||
prefs = flexmock()
|
||||
params_helper = TodosController::TodoCreateParamsHelper.new(params, prefs)
|
||||
assert_nil params_helper.context_name
|
||||
end
|
||||
|
||||
|
||||
def test_project_specified_by_name_is_false_when_project_id_is_specified
|
||||
params = { 'todo' => { 'project_id' => 2 } }
|
||||
prefs = flexmock()
|
||||
params_helper = TodosController::TodoCreateParamsHelper.new(params, prefs)
|
||||
assert_equal false, params_helper.project_specified_by_name?
|
||||
end
|
||||
|
||||
|
||||
def test_project_specified_by_name_is_false_when_project_name_is_blank
|
||||
params = { 'project_name' => nil, 'todo' => {} }
|
||||
prefs = flexmock()
|
||||
params_helper = TodosController::TodoCreateParamsHelper.new(params, prefs)
|
||||
assert_equal false, params_helper.project_specified_by_name?
|
||||
end
|
||||
|
||||
|
||||
def test_project_specified_by_name_is_false_when_project_name_is_none
|
||||
params = { 'project_name' => 'None', 'todo' => {} }
|
||||
prefs = flexmock()
|
||||
params_helper = TodosController::TodoCreateParamsHelper.new(params, prefs)
|
||||
assert_equal false, params_helper.project_specified_by_name?
|
||||
end
|
||||
|
||||
|
||||
def test_context_specified_by_name_is_false_when_context_id_is_specified
|
||||
params = { 'todo' => { 'context_id' => 3 } }
|
||||
prefs = flexmock()
|
||||
params_helper = TodosController::TodoCreateParamsHelper.new(params, prefs)
|
||||
assert_equal false, params_helper.context_specified_by_name?
|
||||
end
|
||||
|
||||
|
||||
def test_context_specified_by_name_is_false_when_context_name_is_blank
|
||||
params = { 'context_name' => nil, 'todo' => {} }
|
||||
prefs = flexmock()
|
||||
params_helper = TodosController::TodoCreateParamsHelper.new(params, prefs)
|
||||
assert_equal false, params_helper.context_specified_by_name?
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue