fix #1310. Add test for this

Found that I had a lot of tests commented out. They have some regressions I will fix later
This commit is contained in:
Reinier Balt 2012-07-15 21:28:42 +02:00
parent 5a24644aad
commit 7c1cd2a144
6 changed files with 696 additions and 694 deletions

View file

@ -518,8 +518,8 @@ var TodoItems = {
ui.draggable.remove();
$('.drop_target').hide();
ajax_options = default_ajax_options_for_scripts('POST', relative_to_root('todos/change_context'), target);
ajax_options.data += "&todo[id]="+dragged_todo + "&todo[context_id]="+context_id
ajax_options = default_ajax_options_for_scripts('POST', relative_to_root('todos/'+dragged_todo + '/change_context'), target);
ajax_options.data += "&todo[context_id]="+context_id
$.ajax(ajax_options);
},
setup_drag_and_drop: function() {

View file

@ -343,7 +343,7 @@ class TodosController < ApplicationController
def remove_predecessor
@source_view = params['_source_view'] || 'todo'
@todo = current_user.todos.find_by_id(params['id']).includes(Todo::DEFAULT_INCLUDES)
@todo = current_user.todos.includes(Todo::DEFAULT_INCLUDES).find_by_id(params['id'])
@predecessor = current_user.todos.find_by_id(params['predecessor'])
@predecessors = @predecessor.predecessors
@successor = @todo
@ -449,8 +449,8 @@ class TodosController < ApplicationController
end
def change_context
# TODO: is this method used?
@todo = Todo.find_by_id(params[:todo][:id])
# change context if you drag a todo to another context
@todo = Todo.find_by_id(params[:id])
@original_item_context_id = @todo.context_id
@context = Context.find_by_id(params[:todo][:context_id])
@todo.context = @context
@ -1225,7 +1225,7 @@ class TodosController < ApplicationController
end
def update_todo_state_if_project_changed
if ( @project_changed ) then
if @project_changed
@todo.update_state_from_project
@remaining_undone_in_project = current_user.projects.find_by_id(@original_item_project_id).todos.active.count if source_view_is :project
end

View file

@ -209,14 +209,14 @@ class Todo < ActiveRecord::Base
end
def update_state_from_project
if self.state == 'project_hidden' and !self.project.hidden?
if self.state == 'project_hidden' && !self.project.hidden?
if self.uncompleted_predecessors.empty?
self.state = 'active'
self.activate!
else
self.state = 'pending'
self.block!
end
elsif self.state == 'active' and self.project.hidden?
self.state = 'project_hidden'
elsif self.state == 'active' && self.project.hidden?
self.hide!
end
self.save!
end

View file

@ -12,7 +12,7 @@ xml.rss :version => "2.0" do
xml.title h(todo.description)
xml.description feed_content_for_todo(todo)
xml.pubDate todo.created_at.to_s(:rfc822)
xml.link todo.project ? project_url(todo.project) : context_url(todo.context)
xml.link (todo.project && !todo.project.is_a?(NullProject)) ? project_url(todo.project) : context_url(todo.context)
xml.guid todo_url(todo)
end
end

View file

@ -88,6 +88,7 @@ Tracksapp::Application.routes.draw do
get 'show_notes'
get 'convert_to_project' # TODO: convert to PUT/POST
get 'remove_predecessor' # TODO: convert to PUT/POST
post 'change_context'
end
collection do
get 'done'

File diff suppressed because it is too large Load diff