From 2101ed6cf8fcafc7286a4c3c77ea85e0bab328c1 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Wed, 3 Dec 2008 14:03:59 +0100 Subject: [PATCH] fix failing tests selenium, unit and functional all pass --- app/controllers/contexts_controller.rb | 3 +++ app/controllers/todos_controller.rb | 5 +++-- app/helpers/todos_helper.rb | 4 ++-- app/views/shared/_add_new_item_form.rhtml | 2 +- app/views/todos/create.js.rjs | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/contexts_controller.rb b/app/controllers/contexts_controller.rb index d09883a4..348151aa 100644 --- a/app/controllers/contexts_controller.rb +++ b/app/controllers/contexts_controller.rb @@ -201,6 +201,9 @@ class ContextsController < ApplicationController :conditions => ['todos.state = ? AND (todos.project_id IS ? OR projects.state = ?)', 'active', nil, 'active'], :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC", :include => [:project, :tags]) + + @projects = current_user.projects + @count = @not_done_todos.size @default_project_context_name_map = build_default_project_context_name_map(@projects).to_json end diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 99824886..8ccf710a 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -399,8 +399,9 @@ class TodosController < ApplicationController :limit => max_completed, :conditions => ['taggings.user_id = ? and state = ?', current_user.id, 'completed'], :order => 'todos.completed_at DESC') - - @contexts = current_user.contexts.find(:all) + + @projects = current_user.projects + @contexts = current_user.contexts @contexts_to_show = @contexts.reject {|x| x.hide? } # Set count badge to number of items with this tag diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 46c30663..06671b26 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -242,13 +242,13 @@ module TodosHelper end def project_names_for_autocomplete - array_or_string_for_javascript( ['None'] + @projects.select{ |p| p.active? }.collect{|p| escape_javascript(p.name) } ) + array_or_string_for_javascript( ['None'] + current_user.projects.active.collect{|p| escape_javascript(p.name) } ) end def context_names_for_autocomplete # #return array_or_string_for_javascript(['Create a new context']) if # @contexts.empty? - array_or_string_for_javascript( @contexts.collect{|c| escape_javascript(c.name) } ) + array_or_string_for_javascript( current_user.contexts.collect{|c| escape_javascript(c.name) } ) end def format_ical_notes(notes) diff --git a/app/views/shared/_add_new_item_form.rhtml b/app/views/shared/_add_new_item_form.rhtml index 65316245..c84e0580 100644 --- a/app/views/shared/_add_new_item_form.rhtml +++ b/app/views/shared/_add_new_item_form.rhtml @@ -2,7 +2,7 @@ @todo = nil @initial_context_name = @context.name unless @context.nil? @initial_context_name ||= @project.default_context.name unless @project.nil? || @project.default_context.nil? - @initial_context_name ||= @contexts[0].name unless @contexts[0].nil? + @initial_context_name ||= current_user.contexts.first.name unless current_user.contexts.first.nil? @initial_project_name = @project.name unless @project.nil? %>
diff --git a/app/views/todos/create.js.rjs b/app/views/todos/create.js.rjs index 404efb75..06d663d3 100644 --- a/app/views/todos/create.js.rjs +++ b/app/views/todos/create.js.rjs @@ -16,7 +16,7 @@ if @saved page.insert_html :top, 'display_box', :partial => 'contexts/context', :locals => { :context => @todo.context, :collapsible => true } else page.call "todoItems.ensureVisibleWithEffectAppear", "c#{@todo.context_id}" if source_view_is_one_of(:todo, :deferred) - page.insert_html :bottom, item_container_id(@todo) + 'items', :partial => 'todos/todo', :locals => { :parent_container_type => parent_container_type, :source_view => @source_view } + page.insert_html :bottom, item_container_id(@todo) + 'items', :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => parent_container_type, :source_view => @source_view } page.visual_effect :highlight, dom_id(@todo), :duration => 3 page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil? end