mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-05 16:58:50 +01:00
Merge pull request #2478 from TracksApp/fix/#2472_calendar_due_edit_fail
#2472: Editing an due date from the calendar causes server error
This commit is contained in:
commit
9eaf8c4c09
2 changed files with 13 additions and 5 deletions
|
|
@ -423,6 +423,7 @@ class TodosController < ApplicationController
|
|||
|
||||
@todo = current_user.todos.find(params['id'])
|
||||
@original_item = current_user.todos.build(@todo.attributes) # create a (unsaved) copy of the original todo
|
||||
@original_item_due_id = get_due_id_for_calendar(@original_item.due)
|
||||
|
||||
update_tags
|
||||
update_project
|
||||
|
|
@ -442,7 +443,6 @@ class TodosController < ApplicationController
|
|||
@saved = false
|
||||
end
|
||||
|
||||
|
||||
provide_project_or_context_for_view
|
||||
|
||||
# this is set after save and cleared after reload, so save it here
|
||||
|
|
@ -1138,18 +1138,18 @@ end
|
|||
end
|
||||
|
||||
def count_old_due_empty(id)
|
||||
due_today_date = Time.zone.now
|
||||
due_this_week_date = Time.zone.now.end_of_week
|
||||
due_next_week_date = due_this_week_date + 7.days
|
||||
due_this_month_date = Time.zone.now.end_of_month
|
||||
case id
|
||||
when "due_today"
|
||||
due_today_date = Time.zone.now
|
||||
return current_user.todos.not_completed.where('todos.due <= ?', due_today_date).count
|
||||
when "due_this_week"
|
||||
due_this_week_date = Time.zone.now.end_of_week
|
||||
return current_user.todos.not_completed.where('todos.due > ? AND todos.due <= ?', due_today_date, due_this_week_date).count
|
||||
when "due_next_week"
|
||||
due_next_week_date = due_this_week_date + 7.days
|
||||
return current_user.todos.not_completed.where('todos.due > ? AND todos.due <= ?', due_this_week_date, due_next_week_date).count
|
||||
when "due_this_month"
|
||||
due_this_month_date = Time.zone.now.end_of_month
|
||||
return current_user.todos.not_completed.where('todos.due > ? AND todos.due <= ?', due_next_week_date, due_this_month_date).count
|
||||
when "due_after_this_month"
|
||||
return current_user.todos.not_completed.where('todos.due > ?', due_this_month_date).count
|
||||
|
|
|
|||
|
|
@ -440,6 +440,14 @@ class TodosControllerTest < ActionController::TestCase
|
|||
assert_equal context.id, todo.reload.context.id, 'context of todo should be changed'
|
||||
end
|
||||
|
||||
def test_update_todo_due_in_calendar_view
|
||||
t = Todo.find(1)
|
||||
login_as(:admin_user)
|
||||
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"=>"31/11/2006"}, "tag_list"=>"foo bar" }
|
||||
t = Todo.find(1)
|
||||
assert_response 200
|
||||
end
|
||||
|
||||
#######
|
||||
# defer
|
||||
#######
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue