#2534: Test setting the due date in calendar view.

This commit is contained in:
Jyri-Petteri Paloposki 2020-12-27 19:48:28 +02:00
parent 813149239f
commit b9b2a3f5d5

View file

@ -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)