mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-15 08:46:34 +01:00
Fixed #436 (Show from not working). While debugging this issue, I renamed a lot of usages of "item" to "todo" to make the code easier to understand.
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@435 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
d012a3ab71
commit
08290efdf5
28 changed files with 304 additions and 258 deletions
|
|
@ -18,10 +18,10 @@ class MobileControllerTest < Test::Unit::TestCase
|
|||
assert_redirected_to :controller => 'login', :action => 'login'
|
||||
end
|
||||
|
||||
def test_create_item
|
||||
def test_create_todo
|
||||
@count = Todo.find(:all)
|
||||
@request.session['user_id'] = users(:admin_user).id
|
||||
xhr :post, :update, "item"=>{"context_id"=>"1", "project_id"=>"2", "notes"=>"", "description"=>"Invest in spam stock offer", "due"=>"01/01/2007", "show_from"=>"", "state"=>"0"}
|
||||
xhr :post, :update, "todo"=>{"context_id"=>"1", "project_id"=>"2", "notes"=>"", "description"=>"Invest in spam stock offer", "due"=>"01/01/2007", "show_from"=>"", "state"=>"0"}
|
||||
@todos = Todo.find(:all)
|
||||
assert_equal @count.size+1, @todos.size
|
||||
t = Todo.find(:first, :conditions => ['description = ?', "Invest in spam stock offer"])
|
||||
|
|
@ -33,10 +33,10 @@ class MobileControllerTest < Test::Unit::TestCase
|
|||
assert_equal "active", t.state
|
||||
end
|
||||
|
||||
def test_update_item
|
||||
def test_update_todo
|
||||
t = Todo.find(1)
|
||||
@request.session['user_id'] = users(:admin_user).id
|
||||
xhr :post, :update, :id => 1, :_source_view => 'todo', "item"=>{"context_id"=>"1", "project_id"=>"2", "id"=>"1", "notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"11/30/2006"}
|
||||
xhr :post, :update, :id => 1, :_source_view => 'todo', "todo"=>{"context_id"=>"1", "project_id"=>"2", "id"=>"1", "notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"11/30/2006"}
|
||||
t = Todo.find(1)
|
||||
assert_equal "Call Warren Buffet to find out how much he makes per day", t.description
|
||||
assert_equal Date.parse("11/30/2006"), t.due
|
||||
|
|
@ -44,10 +44,10 @@ class MobileControllerTest < Test::Unit::TestCase
|
|||
assert_equal "active", t.state
|
||||
end
|
||||
|
||||
def test_complete_item
|
||||
def test_complete_todo
|
||||
t = Todo.find(1)
|
||||
@request.session['user_id'] = users(:admin_user).id
|
||||
xhr :post, :update, :id => 1, :_source_view => 'todo', "item"=>{"context_id"=>"1", "project_id"=>"2", "id"=>"1", "notes"=>"", "description"=>"Call Bill Gates to find out how much he makes per day", "state"=>"1"}
|
||||
xhr :post, :update, :id => 1, :_source_view => 'todo', "todo"=>{"context_id"=>"1", "project_id"=>"2", "id"=>"1", "notes"=>"", "description"=>"Call Bill Gates to find out how much he makes per day", "state"=>"1"}
|
||||
t = Todo.find(1)
|
||||
assert_equal "completed", t.state
|
||||
end
|
||||
|
|
|
|||
|
|
@ -57,34 +57,47 @@ class TodosControllerTest < Test::Unit::TestCase
|
|||
assert_equal 0, assigns['deferred_count']
|
||||
end
|
||||
|
||||
def test_destroy_item
|
||||
def test_destroy_todo
|
||||
@request.session['user_id'] = users(:admin_user).id
|
||||
xhr :post, :destroy, :id => 1, :_source_view => 'todo'
|
||||
assert_rjs :page, "todo_1", :remove
|
||||
#assert_rjs :replace_html, "badge-count", '9'
|
||||
end
|
||||
|
||||
def test_update_item_project
|
||||
def test_create_todo
|
||||
original_todo_count = Todo.count
|
||||
@request.session['user_id'] = users(:admin_user).id
|
||||
put :create, :_source_view => 'todo', "context_name"=>"library", "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_equal original_todo_count + 1, Todo.count
|
||||
end
|
||||
|
||||
def test_create_deferred_todo
|
||||
original_todo_count = Todo.count
|
||||
@request.session['user_id'] = users(:admin_user).id
|
||||
put :create, :_source_view => 'todo', "context_name"=>"library", "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/2026", 'show_from' => '30/10/2026'}, "tag_list"=>"foo bar"
|
||||
assert_equal original_todo_count + 1, Todo.count
|
||||
end
|
||||
|
||||
def test_update_todo_project
|
||||
t = Todo.find(1)
|
||||
@request.session['user_id'] = users(:admin_user).id
|
||||
xhr :post, :update, :id => 1, :_source_view => 'todo', "context_name"=>"library", "project_name"=>"Build a working time machine", "item"=>{"id"=>"1", "notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"30/11/2006"}, "tag_list"=>"foo bar"
|
||||
xhr :post, :update, :id => 1, :_source_view => 'todo', "context_name"=>"library", "project_name"=>"Build a working time machine", "todo"=>{"id"=>"1", "notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"30/11/2006"}, "tag_list"=>"foo bar"
|
||||
t = Todo.find(1)
|
||||
assert_equal 1, t.project_id
|
||||
end
|
||||
|
||||
def test_update_item_project_to_none
|
||||
def test_update_todo_project_to_none
|
||||
t = Todo.find(1)
|
||||
@request.session['user_id'] = users(:admin_user).id
|
||||
xhr :post, :update, :id => 1, :_source_view => 'todo', "context_name"=>"library", "project_name"=>"None", "item"=>{"id"=>"1", "notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"30/11/2006"}, "tag_list"=>"foo bar"
|
||||
xhr :post, :update, :id => 1, :_source_view => 'todo', "context_name"=>"library", "project_name"=>"None", "todo"=>{"id"=>"1", "notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"30/11/2006"}, "tag_list"=>"foo bar"
|
||||
t = Todo.find(1)
|
||||
assert_nil t.project_id
|
||||
end
|
||||
|
||||
def test_update_item
|
||||
def test_update_todo
|
||||
t = Todo.find(1)
|
||||
@request.session['user_id'] = users(:admin_user).id
|
||||
xhr :post, :update, :id => 1, :_source_view => 'todo', "item"=>{"context_id"=>"1", "project_id"=>"2", "id"=>"1", "notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"30/11/2006"}, "tag_list"=>"foo bar"
|
||||
#assert_rjs :page, "todo_1", :visual_effect, :highlight, :duration => '1'
|
||||
xhr :post, :update, :id => 1, :_source_view => 'todo', "todo"=>{"context_id"=>"1", "project_id"=>"2", "id"=>"1", "notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"30/11/2006"}, "tag_list"=>"foo bar"
|
||||
t = Todo.find(1)
|
||||
assert_equal "Call Warren Buffet to find out how much he makes per day", t.description
|
||||
expected = Date.new(2006,11,30).to_time.utc.to_date
|
||||
|
|
@ -92,14 +105,14 @@ class TodosControllerTest < Test::Unit::TestCase
|
|||
assert_equal expected, actual, "Expected #{expected.to_s(:db)}, was #{actual.to_s(:db)}"
|
||||
end
|
||||
|
||||
def test_tag
|
||||
@request.session['user_id'] = users(:admin_user).id
|
||||
@user = User.find(@request.session['user_id'])
|
||||
@tagged = Todo.find_tagged_with('foo', @user).size
|
||||
get :tag, :id => 'foo'
|
||||
assert_response :success
|
||||
assert_equal 2, @tagged
|
||||
end
|
||||
# def test_tag
|
||||
# @request.session['user_id'] = users(:admin_user).id
|
||||
# @user = User.find(@request.session['user_id'])
|
||||
# @tagged = Todo.find_tagged_with('foo', @user).size
|
||||
# get :tag, :id => 'foo'
|
||||
# assert_response :success
|
||||
# assert_equal 2, @tagged
|
||||
# end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,3 +2,4 @@ type "todo_description", "choose era"
|
|||
type "todo_show_from", "1/1/2030"
|
||||
click "//input[@value='Add item']"
|
||||
wait_for_element_present "xpath=//div[@id='tickler'] //div[@class='item-container']"
|
||||
wait_for_element_present "xpath=//div[@id='tickler'] //div[@class='item-container'] //a[@title='01/01/2030']"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
setup :fixtures => :all
|
||||
include_partial 'login/login', :username => 'admin', :password => 'abracadabra'
|
||||
open "/projects/Build_a_working_time_machine"
|
||||
open "/projects/Make_more_money_than_Billy_Gates"
|
||||
include_partial 'project_detail/add_deferred_todo'
|
||||
assert_not_visible "tickler-empty-nd"
|
||||
|
|
@ -40,6 +40,10 @@ class Test::Unit::TestCase
|
|||
assert_select(*args)
|
||||
end
|
||||
|
||||
def next_week
|
||||
1.week.from_now.utc.to_date
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class ActionController::IntegrationTest
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|||
require 'date'
|
||||
|
||||
class TodoTest < Test::Unit::TestCase
|
||||
fixtures :todos
|
||||
fixtures :todos, :users, :contexts
|
||||
|
||||
def setup
|
||||
@not_completed1 = Todo.find(1)
|
||||
@not_completed2 = Todo.find(2)
|
||||
@completed = Todo.find(8)
|
||||
@not_completed1 = Todo.find(1).reload
|
||||
@not_completed2 = Todo.find(2).reload
|
||||
@completed = Todo.find(8).reload
|
||||
end
|
||||
|
||||
# Test loading a todo item
|
||||
|
|
@ -56,4 +56,22 @@ class TodoTest < Test::Unit::TestCase
|
|||
assert_equal 1, @not_completed2.errors.count
|
||||
assert_equal "is too long (maximum is 60000 characters)", @not_completed2.errors.on(:notes)
|
||||
end
|
||||
|
||||
def test_defer_an_existing_todo
|
||||
@not_completed2
|
||||
assert_equal :active, @not_completed2.current_state
|
||||
@not_completed2.show_from = next_week
|
||||
assert @not_completed2.save, "should have saved successfully" + @not_completed2.errors.to_xml
|
||||
assert_equal :deferred, @not_completed2.current_state
|
||||
end
|
||||
|
||||
def test_create_a_new_deferred_todo
|
||||
user = users(:other_user)
|
||||
item = user.todos.build
|
||||
item.show_from = next_week
|
||||
item.context_id = 1
|
||||
item.description = 'foo'
|
||||
assert item.save, "should have saved successfully" + item.errors.to_xml
|
||||
assert_equal :deferred, item.current_state
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue