diff --git a/test/controllers/todos_controller_test.rb b/test/controllers/todos_controller_test.rb index a419492b..79772593 100644 --- a/test/controllers/todos_controller_test.rb +++ b/test/controllers/todos_controller_test.rb @@ -346,6 +346,32 @@ class TodosControllerTest < ActionController::TestCase assert_equal 1, t.project_id end + def test_update_todo_due_date + t = Todo.find(1) + login_as(:admin_user) + + due_today_date = Time.zone.now + due_tomorrow_date = due_today_date + 1.day + due_this_week_date = Time.zone.now.end_of_week - 1.day + due_next_week_date = due_this_week_date + 7.days - 1.day + due_this_month_date = Time.zone.now.end_of_month - 1.day + + post :update, xhr: true, params: { :id => 1, :_source_view => 'calendar', "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"=>due_today_date.strftime("%d/%m/%Y")}, "tag_list"=>"foo bar" } + assert_response 200 + + post :update, xhr: true, params: { :id => 1, :_source_view => 'calendar', "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"=>due_tomorrow_date.strftime("%d/%m/%Y")}, "tag_list"=>"foo bar" } + assert_response 200 + + post :update, xhr: true, params: { :id => 1, :_source_view => 'calendar', "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"=>due_this_week_date.strftime("%d/%m/%Y")}, "tag_list"=>"foo bar" } + assert_response 200 + + post :update, xhr: true, params: { :id => 1, :_source_view => 'calendar', "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"=>due_next_week_date.strftime("%d/%m/%Y")}, "tag_list"=>"foo bar" } + assert_response 200 + + post :update, xhr: true, params: { :id => 1, :_source_view => 'calendar', "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"=>due_this_month_date.strftime("%d/%m/%Y")}, "tag_list"=>"foo bar" } + assert_response 200 + end + def test_update_todo_delete_project t = Todo.find(1) login_as(:admin_user)