mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-08 05:32:37 +01:00
Merge pull request #2477 from TracksApp/fix/#2471_todo_add_fail_context_view
#2471: Adding todo fails in context view
This commit is contained in:
commit
d7f5854d42
2 changed files with 26 additions and 7 deletions
|
|
@ -309,7 +309,7 @@ class TodosController < ApplicationController
|
||||||
@source_view = params['_source_view'] || 'todo'
|
@source_view = params['_source_view'] || 'todo'
|
||||||
|
|
||||||
# Create a (unsaved) copy of the original todo, before it was toggled
|
# Create a (unsaved) copy of the original todo, before it was toggled
|
||||||
@original_item = current_user.todos.build(@todo.attributes)
|
@original_item = current_user.todos.build(@todo.attributes)
|
||||||
@original_completed_period = DoneTodos.completed_period(@todo.completed_at)
|
@original_completed_period = DoneTodos.completed_period(@todo.completed_at)
|
||||||
|
|
||||||
@todo_was_completed_from_deferred_or_blocked_state =
|
@todo_was_completed_from_deferred_or_blocked_state =
|
||||||
|
|
@ -940,7 +940,7 @@ end
|
||||||
@down_count = current_user.todos.active.not_hidden.count
|
@down_count = current_user.todos.active.not_hidden.count
|
||||||
end
|
end
|
||||||
from.context do
|
from.context do
|
||||||
context_id = @original_item.context_id || @todo.context_id
|
context_id = @original_item ? @original_item.context_id || @todo.context_id : @todo.context_id
|
||||||
todos = current_user.contexts.find(context_id).todos.not_completed
|
todos = current_user.contexts.find(context_id).todos.not_completed
|
||||||
|
|
||||||
if @todo.context.hidden?
|
if @todo.context.hidden?
|
||||||
|
|
|
||||||
|
|
@ -223,14 +223,33 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
login_as(:admin_user)
|
login_as(:admin_user)
|
||||||
assert_difference 'Todo.count' do
|
assert_difference 'Todo.count' do
|
||||||
put :create, xhr: true, params: {
|
put :create, xhr: true, params: {
|
||||||
"context_name"=>"library",
|
"context_name" => "library",
|
||||||
"project_name"=>"Build a working time machine",
|
"project_name" => "Build a working time machine",
|
||||||
"todo" => {
|
"todo" => {
|
||||||
"notes"=>"",
|
"notes" => "",
|
||||||
"description" => "Call Warren Buffet to find out how much he makes per day",
|
"description" => "Call Warren Buffet to find out how much he makes per day",
|
||||||
"due"=>"30/11/2006"
|
"due" => "30/11/2006"
|
||||||
},
|
},
|
||||||
"tag_list"=>"foo bar"
|
"tag_list" => "foo bar"
|
||||||
|
}
|
||||||
|
assert_response 200
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_create_todo_via_xhr_context_view
|
||||||
|
login_as(:admin_user)
|
||||||
|
assert_difference 'Todo.count' do
|
||||||
|
put :create, xhr: true, params: {
|
||||||
|
"context_name" => "library",
|
||||||
|
"project_name" => "",
|
||||||
|
"todo" => {
|
||||||
|
"notes" => "",
|
||||||
|
"description" => "Read Warren Buffet's book",
|
||||||
|
"due" => "30/12/2006"
|
||||||
|
},
|
||||||
|
"_source_view" => "context",
|
||||||
|
"default_context_name" => "library",
|
||||||
|
"tag_list" => "bar foo"
|
||||||
}
|
}
|
||||||
assert_response 200
|
assert_response 200
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue