mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-23 10:40:13 +01:00
Fixes #432: Could not successfully set project to None while editing a Todo.
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@422 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
eb1709b053
commit
6045a7a986
3 changed files with 27 additions and 3 deletions
|
|
@ -130,7 +130,10 @@ class TodosController < ApplicationController
|
||||||
@original_item_context_id = @item.context_id
|
@original_item_context_id = @item.context_id
|
||||||
@original_item_project_id = @item.project_id
|
@original_item_project_id = @item.project_id
|
||||||
@original_item_was_deferred = @item.deferred?
|
@original_item_was_deferred = @item.deferred?
|
||||||
if params['item']['project_id'].blank? && !params['project_name'].blank? && params['project_name'] != 'None'
|
if params['item']['project_id'].blank? && !params['project_name'].blank?
|
||||||
|
if params['project_name'] == 'None'
|
||||||
|
project = Project.null_object
|
||||||
|
else
|
||||||
project = @user.projects.find_by_name(params['project_name'].strip)
|
project = @user.projects.find_by_name(params['project_name'].strip)
|
||||||
unless project
|
unless project
|
||||||
project = @user.projects.build
|
project = @user.projects.build
|
||||||
|
|
@ -138,6 +141,7 @@ class TodosController < ApplicationController
|
||||||
project.save
|
project.save
|
||||||
@new_project_created = true
|
@new_project_created = true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
params["item"]["project_id"] = project.id
|
params["item"]["project_id"] = project.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,4 +109,8 @@ class NullProject
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def id
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
@ -64,6 +64,22 @@ class TodosControllerTest < Test::Unit::TestCase
|
||||||
#assert_rjs :replace_html, "badge-count", '9'
|
#assert_rjs :replace_html, "badge-count", '9'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_update_item_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"
|
||||||
|
t = Todo.find(1)
|
||||||
|
assert_equal 1, t.project_id
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_update_item_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"
|
||||||
|
t = Todo.find(1)
|
||||||
|
assert_nil t.project_id
|
||||||
|
end
|
||||||
|
|
||||||
def test_update_item
|
def test_update_item
|
||||||
t = Todo.find(1)
|
t = Todo.find(1)
|
||||||
@request.session['user_id'] = users(:admin_user).id
|
@request.session['user_id'] = users(:admin_user).id
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue