migrate toggle_check and destroy and defer and get the functional tests running again

This commit is contained in:
Reinier Balt 2011-01-06 23:01:17 +01:00
parent 7a893980c2
commit a832417c59
33 changed files with 412 additions and 314 deletions

View file

@ -48,7 +48,7 @@ class ProjectsController < ApplicationController
init_data_for_sidebar unless mobile?
@page_title = t('projects.page_title', :project => @project.name)
@not_done = @project.not_done_todos_including_hidden
@not_done = @project.todos.active_or_hidden
@deferred = @project.deferred_todos
@pending = @project.pending_todos
@done = @project.todos.find_in_state(:all, :completed, :order => "todos.completed_at DESC", :limit => current_user.prefs.show_number_completed, :include => [:context])
@ -128,10 +128,10 @@ class ProjectsController < ApplicationController
if boolean_param('wants_render')
if (@project.hidden?)
@project_project_hidden_todo_counts = Hash.new
@project_project_hidden_todo_counts[@project.id] = @project.reload().not_done_todos_including_hidden.count
@project_project_hidden_todo_counts[@project.id] = @project.reload().todos.active_or_hidden.count
else
@project_not_done_counts = Hash.new
@project_not_done_counts[@project.id] = @project.reload().not_done_todos_including_hidden.count
@project_not_done_counts[@project.id] = @project.reload().todos.active_or_hidden.count
end
@contexts = current_user.contexts
update_state_counts

View file

@ -5,10 +5,12 @@ class TodosController < ApplicationController
skip_before_filter :login_required, :only => [:index, :calendar]
prepend_before_filter :login_or_feed_token_required, :only => [:index, :calendar]
append_before_filter :find_and_activate_ready, :only => [:index, :list_deferred]
# TODO: replace :except with :only
append_before_filter :init, :except => [ :tag, :destroy, :completed,
:completed_archive, :check_deferred, :toggle_check, :toggle_star,
:edit, :update, :create, :calendar, :auto_complete_for_predecessor, :remove_predecessor, :add_predecessor]
append_before_filter :get_todo_from_params, :only => [ :edit, :toggle_check, :toggle_star, :show, :update, :destroy, :remove_predecessor, :show_notes]
:edit, :update, :defer, :create, :calendar, :auto_complete_for_predecessor, :remove_predecessor, :add_predecessor]
protect_from_forgery :except => [:auto_complete_for_predecessor]
def index
@ -84,8 +86,8 @@ class TodosController < ApplicationController
# Fix for #977 because AASM overrides @state on creation
@todo.update_attribute('state', specified_state) unless specified_state == "immediate"
@todo.update_state_from_project
@saved = @todo.save
@todo.update_state_from_project if @saved
unless (@saved == false) || tag_list.blank?
@todo.tag_with(tag_list)
@ -99,7 +101,7 @@ class TodosController < ApplicationController
@todo.save
end
@todo.reload
@todo.reload if @saved
respond_to do |format|
format.html { redirect_to :action => "index" }
@ -198,8 +200,7 @@ class TodosController < ApplicationController
end
def edit
@projects = current_user.projects.find(:all)
@contexts = current_user.contexts.find(:all)
@todo = current_user.todos.find(params['id'], :include => [:project, :context, :tags, :taggings, :predecessors])
@source_view = params['_source_view'] || 'todo'
@tag_name = params['_tag_name']
respond_to do |format|
@ -208,6 +209,7 @@ class TodosController < ApplicationController
end
def show
@todo = current_user.todos.find(params['id'])
respond_to do |format|
format.m do
@projects = current_user.projects.active
@ -235,6 +237,7 @@ class TodosController < ApplicationController
end
def remove_predecessor
@todo = current_user.todos.find(params['id'])
@source_view = params['_source_view'] || 'todo'
@predecessor = current_user.todos.find(params['predecessor'])
@successor = @todo
@ -247,6 +250,7 @@ class TodosController < ApplicationController
# Toggles the 'done' status of the action
#
def toggle_check
@todo = current_user.todos.find(params['id'])
@source_view = params['_source_view'] || 'todo'
@original_item_due = @todo.due
@original_item_was_deferred = @todo.deferred?
@ -273,7 +277,8 @@ class TodosController < ApplicationController
determine_remaining_in_context_count(@todo.context_id)
determine_down_count
determine_completed_count
determine_deferred_tag_count(params['_tag_name']) if @source_view == 'tag'
determine_deferred_tag_count(params['_tag_name']) if source_view_is(:tag)
@wants_redirect_after_complete = @todo.completed? && !@todo.project_id.nil? && current_user.prefs.show_project_on_todo_done && !source_view_is(:project)
if source_view_is :calendar
@original_item_due_id = get_due_id_for_calendar(@original_item_due)
@old_due_empty = is_old_due_empty(@original_item_due_id)
@ -296,8 +301,9 @@ class TodosController < ApplicationController
end
def toggle_star
@todo = current_user.todos.find(params['id'], :include => [:taggings, :tags])
@todo.toggle_star!
@saved = @todo.save!
@saved = true # cannot determine error
respond_to do |format|
format.js
format.xml { render :xml => @todo.to_xml( :except => :user_id ) }
@ -306,6 +312,7 @@ class TodosController < ApplicationController
end
def change_context
# TODO: is this method used?
@todo = Todo.find(params[:todo][:id])
@original_item_context_id = @todo.context_id
@context = Context.find(params[:todo][:context_id])
@ -323,6 +330,7 @@ class TodosController < ApplicationController
end
def update
@todo = current_user.todos.find(params['id'])
@source_view = params['_source_view'] || 'todo'
init_data_for_sidebar unless mobile?
@ -344,7 +352,7 @@ class TodosController < ApplicationController
determine_changes_by_this_update
determine_remaining_in_context_count(@context_changed ? @original_item_context_id : @todo.context_id)
determine_down_count
determine_deferred_tag_count(params['_tag_name']) if @source_view == 'tag'
determine_deferred_tag_count(params['_tag_name']) if source_view_is(:tag)
respond_to do |format|
format.js {
@ -371,7 +379,7 @@ class TodosController < ApplicationController
def destroy
@source_view = params['_source_view'] || 'todo'
@todo = get_todo_from_params
@todo = current_user.todos.find(params['id'], :include => [:pending_successors, :uncompleted_predecessors, :taggings, :tags, :project, :context])
@original_item_due = @todo.due
@context_id = @todo.context_id
@project_id = @todo.project_id
@ -491,7 +499,7 @@ class TodosController < ApplicationController
@tag = Tag.find_by_name(@tag_name)
@tag = Tag.new(:name => @tag_name) if @tag.nil?
@not_done_todos = current_user.todos.with_tag(@tag).active.find(:all,
@not_done_todos = current_user.todos.with_tag(@tag).active.not_hidden.find(:all,
:order => 'todos.due IS NULL, todos.due ASC, todos.created_at ASC', :include => [:context])
@hidden_todos = current_user.todos.with_tag(@tag).hidden.find(:all,
:include => [:taggings, :tags, :context],
@ -541,16 +549,29 @@ class TodosController < ApplicationController
def defer
@source_view = params['_source_view'] || 'todo'
numdays = params['days'].to_i
@todo = Todo.find(params[:id])
@todo = current_user.todos.find(params[:id], :include => [:taggings, :tags, :uncompleted_predecessors, :pending_successors])
@original_item_context_id = @todo.context_id
@todo_deferred_state_changed = true
@new_context_created = false
@due_date_changed = false
@tag_was_removed = false
@todo_hidden_state_changed = false
@todo_was_deferred_from_active_state = @todo.show_from.nil?
@todo.show_from = (@todo.show_from || @todo.user.date) + numdays.days
@saved = @todo.save
determine_down_count
determine_remaining_in_context_count(@todo.context_id)
if @source_view == 'project'
@remaining_undone_in_project = current_user.projects.find(@todo.project_id).not_done_todos.count
@original_item_project_id = @todo.project_id
source_view do |page|
page.project {
@remaining_undone_in_project = current_user.projects.find(@todo.project_id).todos.not_completed.count
@original_item_project_id = @todo.project_id
}
page.tag {
determine_deferred_tag_count(params['_tag_name'])
}
end
respond_to do |format|
@ -652,6 +673,7 @@ class TodosController < ApplicationController
end
def show_notes
@todo = current_user.todos.find(params['id'])
@return_path=cookies[:mobile_url] ? cookies[:mobile_url] : mobile_path
respond_to do |format|
format.html {
@ -666,6 +688,8 @@ class TodosController < ApplicationController
private
def get_todo_from_params
# TODO: this was a :append_before but was removed to tune performance per
# method. Reconsider re-enabling it
@todo = current_user.todos.find(params['id'])
end
@ -806,14 +830,14 @@ class TodosController < ApplicationController
def determine_down_count
source_view do |from|
from.todo do
@down_count = current_user.todos.not_hidden.count(:all)
@down_count = current_user.todos.active.not_hidden.count(:all)
end
from.context do
@down_count = current_user.contexts.find(@todo.context_id).todos.not_completed.count(:all)
end
from.project do
unless @todo.project_id == nil
@down_count = current_user.projects.find(@todo.project_id).not_done_todos_including_hidden.count
@down_count = current_user.projects.find(@todo.project_id).todos.active_or_hidden.count
end
end
from.deferred do
@ -825,8 +849,7 @@ class TodosController < ApplicationController
if @tag.nil?
@tag = Tag.new(:name => @tag_name)
end
@not_done_todos = current_user.todos.with_tag(@tag).active.find(:all)
@not_done_todos.empty? ? @down_count = 0 : @down_count = @not_done_todos.size
@down_count = current_user.todos.with_tag(@tag).active.not_hidden.count
end
end
end
@ -843,8 +866,8 @@ class TodosController < ApplicationController
if tag.nil?
tag = Tag.new(:name => params['tag'])
end
@remaining_in_context = current_user.contexts.find(context_id).todos.not_hidden.with_tag(tag).count
@target_context_count = current_user.contexts.find(@todo.context_id).todos.not_hidden.with_tag(tag).count
@remaining_in_context = current_user.contexts.find(context_id).todos.active.not_hidden.with_tag(tag).count
@target_context_count = current_user.contexts.find(@todo.context_id).todos.active.not_hidden.with_tag(tag).count
if !@todo.hidden? && @todo_hidden_state_changed
@remaining_hidden_count = current_user.todos.hidden.with_tag(tag).count
end
@ -856,10 +879,10 @@ class TodosController < ApplicationController
}
from.calendar {
@target_context_count = count_old_due_empty(@new_due_id)
}
}
end
@remaining_in_context = current_user.contexts.find(context_id).todos(true).not_hidden.count if !@remaining_in_context
@target_context_count = current_user.contexts.find(@todo.context_id).todos(true).not_hidden.count if !@target_context_count
@remaining_in_context = current_user.contexts.find(context_id).todos(true).active.not_hidden.count if !@remaining_in_context
@target_context_count = current_user.contexts.find(@todo.context_id).todos(true).active.not_hidden.count if !@target_context_count
end
def determine_completed_count
@ -894,16 +917,7 @@ class TodosController < ApplicationController
@done = current_user.completed_todos.find(:all, :limit => max_completed, :include => [ :context, :project, :tags ]) unless max_completed == 0
# Set count badge to number of not-done, not hidden context items
@count = 0
@todos.each do |x|
if x.active?
if x.project.nil?
@count += 1 if !x.context.hide?
else
@count += 1 if x.project.active? && !x.context.hide?
end
end
end
@count = current_user.todos.active.not_hidden.count(:all)
render
end
@ -1066,6 +1080,142 @@ class TodosController < ApplicationController
end
end
def cache_attributes_from_before_update
@original_item_context_id = @todo.context_id
@original_item_project_id = @todo.project_id
@original_item_was_deferred = @todo.deferred?
@original_item_was_hidden = @todo.hidden?
@original_item_due = @todo.due
@original_item_due_id = get_due_id_for_calendar(@todo.due)
@original_item_predecessor_list = @todo.predecessors.map{|t| t.specification}.join(', ')
end
def update_project
@project_changed = false;
if params['todo']['project_id'].blank? && !params['project_name'].nil?
if params['project_name'] == 'None'
project = Project.null_object
else
project = current_user.projects.find_by_name(params['project_name'].strip)
unless project
project = current_user.projects.build
project.name = params['project_name'].strip
project.save
@new_project_created = true
end
end
params["todo"]["project_id"] = project.id
@project_changed = @original_item_project_id != params["todo"]["project_id"] = project.id
end
end
def update_todo_state_if_project_changed
if ( @project_changed ) then
@todo.update_state_from_project
@remaining_undone_in_project = current_user.projects.find(@original_item_project_id).todos.active.count if source_view_is :project
end
end
def update_context
@context_changed = false
if params['todo']['context_id'].blank? && !params['context_name'].blank?
context = current_user.contexts.find_by_name(params['context_name'].strip)
unless context
@new_context = current_user.contexts.build
@new_context.name = params['context_name'].strip
@new_context.save
@new_context_created = true
@not_done_todos = [@todo]
context = @new_context
end
params["todo"]["context_id"] = context.id
@context_changed = @original_item_context_id != params["todo"]["context_id"] = context.id
end
end
def update_tags
if params[:tag_list]
@todo.tag_with(params[:tag_list])
@todo.tags(true) #force a reload for proper rendering
end
end
def update_due_and_show_from_dates
if params["todo"].has_key?("due")
params["todo"]["due"] = parse_date_per_user_prefs(params["todo"]["due"])
else
params["todo"]["due"] = ""
end
if params['todo']['show_from']
params['todo']['show_from'] = parse_date_per_user_prefs(params['todo']['show_from'])
end
end
def update_completed_state
if params['done'] == '1' && !@todo.completed?
@todo.complete!
@todo.pending_to_activate.each do |t|
t.activate!
end
end
# strange. if checkbox is not checked, there is no 'done' in params.
# Therefore I've used the negation
if !(params['done'] == '1') && @todo.completed?
@todo.activate!
@todo.active_to_block.each do |t|
t.block!
end
end
end
def update_dependencies
@todo.add_predecessor_list(params[:predecessor_list])
if @original_item_predecessor_list != params[:predecessor_list]
# Possible state change with new dependencies
if @todo.uncompleted_predecessors.empty?
@todo.activate! if @todo.state == 'pending' # Activate pending if no uncompleted predecessors
else
@todo.block! if @todo.state == 'active' # Block active if we got uncompleted predecessors
end
end
end
def update_attributes_of_todo
@todo.attributes = params["todo"]
end
def determine_changes_by_this_update
@todo_was_activated_from_deferred_state = @original_item_was_deferred && @todo.active?
@todo_was_deferred_from_active_state = @todo.deferred? && !@original_item_was_deferred
@todo_deferred_state_changed = @todo_was_deferred_from_active_state || @todo_was_activated_from_deferred_state
@due_date_changed = @original_item_due != @todo.due
@todo_hidden_state_changed = @original_item_was_hidden != @todo.hidden?
source_view do |page|
page.calendar do
@old_due_empty = is_old_due_empty(@original_item_due_id)
@new_due_id = get_due_id_for_calendar(@todo.due) if @due_date_changed
end
page.tag do
@tag_name = params['_tag_name']
@tag_was_removed = !@todo.has_tag?(@tag_name)
end
end
end
def project_specified_by_name(project_name)
return false unless params['project_id'].blank?
return false if project_name.blank?
return false if project_name == 'None'
true
end
def context_specified_by_name(context_name)
return false unless params['context_id'].blank?
return false if context_name.blank?
true
end
class FindConditionBuilder
def initialize
@ -1140,140 +1290,4 @@ class TodosController < ApplicationController
end
private
def cache_attributes_from_before_update
@original_item_context_id = @todo.context_id
@original_item_project_id = @todo.project_id
@original_item_was_deferred = @todo.deferred?
@original_item_was_hidden = @todo.hidden?
@original_item_due = @todo.due
@original_item_due_id = get_due_id_for_calendar(@todo.due)
@original_item_predecessor_list = @todo.predecessors.map{|t| t.specification}.join(', ')
end
def update_project
if params['todo']['project_id'].blank? && !params['project_name'].nil?
if params['project_name'] == 'None'
project = Project.null_object
else
project = current_user.projects.find_by_name(params['project_name'].strip)
unless project
project = current_user.projects.build
project.name = params['project_name'].strip
project.save
@new_project_created = true
end
end
params["todo"]["project_id"] = project.id
end
@project_changed = @original_item_project_id != params["todo"]["project_id"] = project.id
end
def update_todo_state_if_project_changed
if ( @project_changed ) then
@todo.update_state_from_project
@remaining_undone_in_project = current_user.projects.find(@original_item_project_id).todos.active.count if source_view_is :project
end
end
def update_context
if params['todo']['context_id'].blank? && !params['context_name'].blank?
context = current_user.contexts.find_by_name(params['context_name'].strip)
unless context
@new_context = current_user.contexts.build
@new_context.name = params['context_name'].strip
@new_context.save
@new_context_created = true
@not_done_todos = [@todo]
context = @new_context
end
params["todo"]["context_id"] = context.id
end
@context_changed = @original_item_context_id != params["todo"]["context_id"] = context.id
end
def update_tags
if params[:tag_list]
@todo.tag_with(params[:tag_list])
@todo.tags(true) #force a reload for proper rendering
end
end
def update_due_and_show_from_dates
if params["todo"].has_key?("due")
params["todo"]["due"] = parse_date_per_user_prefs(params["todo"]["due"])
else
params["todo"]["due"] = ""
end
if params['todo']['show_from']
params['todo']['show_from'] = parse_date_per_user_prefs(params['todo']['show_from'])
end
end
def update_completed_state
if params['done'] == '1' && !@todo.completed?
@todo.complete!
@todo.pending_to_activate.each do |t|
t.activate!
end
end
# strange. if checkbox is not checked, there is no 'done' in params.
# Therefore I've used the negation
if !(params['done'] == '1') && @todo.completed?
@todo.activate!
@todo.active_to_block.each do |t|
t.block!
end
end
end
def update_dependencies
@todo.add_predecessor_list(params[:predecessor_list])
if @original_item_predecessor_list != params[:predecessor_list]
# Possible state change with new dependencies
if @todo.uncompleted_predecessors.empty?
@todo.activate! if @todo.state == 'pending' # Activate pending if no uncompleted predecessors
else
@todo.block! if @todo.state == 'active' # Block active if we got uncompleted predecessors
end
end
end
def update_attributes_of_todo
@todo.attributes = params["todo"]
end
def determine_changes_by_this_update
@todo_was_activated_from_deferred_state = @original_item_was_deferred && @todo.active?
@todo_was_deferred_from_active_state = @todo.deferred? && !@original_item_was_deferred
@todo_deferred_state_changed = @todo_was_deferred_from_active_state || @todo_was_activated_from_deferred_state
@due_date_changed = @original_item_due != @todo.due
@todo_hidden_state_changed = @original_item_was_hidden != @todo.hidden?
source_view do |page|
page.calendar do
@old_due_empty = is_old_due_empty(@original_item_due_id)
@new_due_id = get_due_id_for_calendar(@todo.due) if @due_date_changed
end
page.tag do
@tag_name = params['_tag_name']
@tag_was_removed = !@todo.has_tag?(@tag_name)
end
end
end
def project_specified_by_name(project_name)
return false unless params['project_id'].blank?
return false if project_name.blank?
return false if project_name == 'None'
true
end
def context_specified_by_name(context_name)
return false unless params['context_id'].blank?
return false if context_name.blank?
true
end
end
end

View file

@ -170,7 +170,7 @@ module ApplicationHelper
end
def render_flash
render :partial => 'shared/flash', :locals => { :flash => flash }
render :partial => 'shared/flash', :object => flash
end
def recurrence_time_span(rt)

View file

@ -27,20 +27,15 @@ module TodosHelper
url = {:controller => 'todos', :action => 'defer', :id => todo.id, :days => days,
:_source_view => (@source_view.underscore.gsub(/\s+/,'_') rescue "")}
url[:_tag_name] = @tag_name if @source_view == 'tag'
futuredate = (@todo.show_from || @todo.user.date) + days.days
options = {:x_defer_alert => false, :class => "icon_defer_item" }
if @todo.due && futuredate > @todo.due
return link_to_function(
image_tag("defer_#{days}_off.png", :mouseover => "defer_#{days}.png", :alt => t('todos.defer_x_days', :count => days), :align => "absmiddle")+" "+t('todos.defer_x_days', :count => days),
"alert('#{t('todos.defer_date_after_due_date')}')"
)
else
return link_to_remote(
image_tag("defer_#{days}_off.png", :mouseover => "defer_#{days}.png", :alt => t('todos.defer_x_days', :count => days), :align => "absmiddle")+" "+t('todos.defer_x_days', :count => days),
:url => url,
:before => todo_start_waiting_js(todo),
:complete => todo_stop_waiting_js(todo))
options[:x_defer_alert] = true
options[:x_defer_date_after_due_date] = t('todos.defer_date_after_due_date')
end
return link_to(image_tag_for_defer(days), url, options)
end
def remote_promote_to_project_menu_item(todo)
@ -51,6 +46,10 @@ module TodosHelper
return link_to(image_tag("to_project_off.png", :align => "absmiddle")+" " + t('todos.convert_to_project'), url)
end
def image_tag_for_defer(days)
image_tag("defer_#{days}_off.png", :mouseover => "defer_#{days}.png", :alt => t('todos.defer_x_days', :count => days), :align => "absmiddle")+" "+t('todos.defer_x_days', :count => days)
end
# waiting stuff can be deleted after migration of defer
def todo_start_waiting_js(todo)
return "$('#ul#{dom_id(todo)}').css('visibility', 'hidden'); $('##{dom_id(todo)}').block({message: null})"
@ -264,7 +263,9 @@ module TodosHelper
end
def update_needs_to_hide_context
return false if source_view_is(:tag) && (@remaining_in_context == 0) && (@todo_hidden_state_changed && !@todo.hidden?)
return (@remaining_in_context == 0 && (@todo_hidden_state_changed && @todo.hidden?)) ||
(@remaining_in_context == 0 && @todo_was_deferred_from_active_state) if source_view_is(:tag)
return (@remaining_in_context == 0) && !source_view_is(:context)
end
@ -312,6 +313,7 @@ module TodosHelper
return "c#{todo.context_id}items" if source_view_is :deferred
return @new_due_id if source_view_is :calendar
return "tickleritems" if !source_view_is(:todo) && (todo.deferred? || todo.pending?)
return "completed_containeritems" if todo.completed?
return "p#{todo.project_id}items" if source_view_is :project
return "c#{todo.context_id}items"
end
@ -348,7 +350,9 @@ module TodosHelper
page.calendar { container_id = "empty_#{@original_item_due_id}" if @old_due_empty }
page.tag {
container_id = "hidden-empty-nd" if !@todo.hidden? && @todo_hidden_state_changed && @remaining_hidden_count == 0
container_id = "tickler-empty-nd" if @todo_was_activated_from_deferred_state && @remaining_deferred_or_pending_count == 0
container_id = "tickler-empty-nd" if (@todo_was_activated_from_deferred_state && @remaining_deferred_or_pending_count == 0) ||
(@original_item_was_deferred && @deferred_tag_count == 0 && @todo.completed?)
container_id = "empty-d" if @completed_count && @completed_count == 0 && !@todo.completed?
}
page.context { container_id = "c#{@original_item_context_id}empty-nd" if @remaining_in_context == 0 }
page.todo { container_id = "c#{@original_item_context_id}empty-nd" if @remaining_in_context == 0 }

View file

@ -1,5 +1,5 @@
class Project < ActiveRecord::Base
has_many :todos, :dependent => :delete_all, :include => [:context,:tags]
has_many :todos, :dependent => :delete_all
# TODO: remove these scopes. Can be replaced by the named scopes on the todo relation
has_many :not_done_todos,
@ -7,11 +7,6 @@ class Project < ActiveRecord::Base
:class_name => 'Todo',
:order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC",
:conditions => ["todos.state = ?", 'active']
has_many :not_done_todos_including_hidden,
:include => [:context,:tags,:project],
:class_name => 'Todo',
:order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC",
:conditions => ["(todos.state = ? OR todos.state = ?)", 'active', 'project_hidden']
has_many :done_todos,
:include => [:context,:tags,:project],
:class_name => 'Todo',

View file

@ -17,6 +17,7 @@ class Todo < ActiveRecord::Base
after_save :save_predecessors
named_scope :active, :conditions => { :state => 'active' }
named_scope :active_or_hidden, :conditions => ["todos.state = ? OR todos.state = ?", 'active', 'project_hidden']
named_scope :not_completed, :conditions => ['NOT (todos.state = ? )', 'completed']
named_scope :completed, :conditions => ["NOT todos.completed_at IS NULL"]
named_scope :are_due, :conditions => ['NOT (todos.due IS NULL)']
@ -215,7 +216,7 @@ class Todo < ActiveRecord::Base
end
def update_state_from_project
if state == 'project_hidden' and !self.project.hidden?
if self.state == 'project_hidden' and !self.project.hidden?
if self.uncompleted_predecessors.empty?
self.state = 'active'
else
@ -224,6 +225,7 @@ class Todo < ActiveRecord::Base
elsif self.state == 'active' and self.project.hidden?
self.state = 'project_hidden'
end
self.save!
end
def toggle_completion!

View file

@ -1,9 +1,8 @@
<div id="display_box">
<%= render :partial => "contexts/context", :locals => { :context => @context, :collapsible => false } %>
<%= render :partial => "contexts/context", :object => @context, :locals => { :collapsible => false } %>
<% unless @max_completed==0 -%>
<%= render :partial => "todos/completed", :locals => { :done => @done, :suppress_context => true, :collapsible => false, :append_descriptor => t('contexts.last_completed_in_context', :number=>prefs.show_number_completed) } %>
<%= render :partial => "todos/completed", :object => @done, :locals => { :suppress_context => true, :collapsible => false, :append_descriptor => t('contexts.last_completed_in_context', :number=>prefs.show_number_completed) } %>
<% end -%>
</div><!-- [end:display_box] -->
<div id="input_box">

View file

@ -12,9 +12,9 @@
<title><%= @page_title %></title>
</head><body>
<% if !(@new_mobile || @edit_mobile)
if !@prefs.nil? -%>
<h1><span class="count"><%= @down_count %></span> <%=
l(Date.today, :format => @prefs.title_date_format) -%></h1>
if !current_user.prefs.nil? -%>
<h1><span class="count"><%= @down_count %></span> <%=
l(Date.today, :format => current_user.prefs.title_date_format) -%></h1>
<div class="nav">
<%= (link_to(t('layouts.mobile_navigation.new_action'), new_todo_path(new_todo_params))+" | ") unless @new_mobile -%>
<%= (link_to(t('layouts.mobile_navigation.home'), todos_path(:format => 'm'))+" | ") unless @home -%>
@ -25,7 +25,7 @@
end -%><%= render_flash -%>
</div>
<%= yield -%>
<hr/><% if !@prefs.nil? -%>
<hr/><% if !current_user.prefs.nil? -%>
<div class="nav">
<%= (link_to(t('layouts.mobile_navigation.logout'), logout_path(:format => 'm')) +" | ") -%>
<%= (link_to(t('layouts.mobile_navigation.new_action'), new_todo_path(new_todo_params), {:accesskey => "0"})+" | ") unless @new_mobile -%>

View file

@ -15,8 +15,8 @@
var dateFormat = '<%= date_format_for_date_picker %>';
var weekStart = '<%= current_user.prefs.week_starts %>';
function relative_to_root(path) { return '<%= root_url %>'+path; };
<% if @prefs.refresh != 0 -%>
setup_auto_refresh(<%= @prefs["refresh"].to_i*60000 %>);
<% if current_user.prefs.refresh != 0 -%>
setup_auto_refresh(<%= current_user.prefs["refresh"].to_i*60000 %>);
<% end -%>
<% unless @controller_name == 'feed' or session['noexpiry'] == "on" -%>
setup_periodic_check("<%=url_for(:controller => "login", :action => "check_expiry")%>", 5*60);
@ -36,7 +36,7 @@
<% if @count -%>
<span id="badge_count" class="badge"><%= @count %></span>
<% end -%>
<%= l(Date.today, :format => @prefs.title_date_format) %>
<%= l(Date.today, :format => current_user.prefs.title_date_format) %>
</h1>
</div>
<div id="minilinks">

View file

@ -1,6 +1,6 @@
<% if @saved -%>
<% if @go_to_project -%>
redirect_to ("<%= project_path(@project) -%>")
redirect_to("<%= project_path(@project) -%>")
<% else -%>
TracksPages.hide_errors();
hide_empty_message();

View file

@ -6,7 +6,7 @@
<%= render :partial => @project, :locals => {:collapsible => false } %>
<%= render :partial => "todos/deferred", :locals => { :deferred => @deferred, :collapsible => false, :append_descriptor => t('projects.todos_append'), :parent_container_type => 'project', :pending => @pending } %>
<% unless @max_completed==0 -%>
<%= render :partial => "todos/completed", :locals => { :done => @done, :collapsible => false, :suppress_project => true, :append_descriptor => t('projects.todos_append') } %>
<%= render :partial => "todos/completed", :object => @done, :locals => { :collapsible => false, :suppress_project => true, :append_descriptor => t('projects.todos_append') } %>
<% end -%>
<div class="container">

View file

@ -11,10 +11,10 @@
</h2>
<div id="completed_containeritems" class="items toggle_target">
<div id="empty-d" style="display:<%= @done.empty? ? 'block' : 'none' %>">
<div id="empty-d" style="display:<%= completed.empty? ? 'block' : 'none' %>">
<div class="message"><p><%= t('todos.no_completed_actions') %></p></div>
</div>
<%= render :partial => "todos/todo", :collection => done, :locals => { :parent_container_type => "completed", :suppress_context => suppress_context, :suppress_project => suppress_project } %>
<%= render :partial => "todos/todo", :collection => completed, :locals => { :parent_container_type => "completed", :suppress_context => suppress_context, :suppress_project => suppress_project } %>
</div>
</div><!-- [end:next_actions] -->

View file

@ -15,7 +15,7 @@
<% end %>
<% if done.notes? -%>
<%= render :partial => "todos/toggle_notes", :locals => { :item => done } %>
<%= render :partial => "todos/toggle_notes", :object => done %>
<% end -%>
</td>
<% end %>

View file

@ -19,7 +19,7 @@ parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag'
:before => successor_start_waiting_js(successor)},
{:style => "background: transparent;"}) %>
<%= render(:partial => "todos/toggle_successors", :locals => { :item => successor, :suppress_button => true }) unless successor.pending_successors.empty? %>
<%= render(:partial => "todos/toggle_successors", :object => successor, :locals => { :suppress_button => true }) unless successor.pending_successors.empty? %>
</div>
</div>
</div>

View file

@ -32,8 +32,8 @@ parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag'
<%= tag_list %>
<%= deferred_due_date %>
<%= project_and_context_links( parent_container_type, :suppress_context => suppress_context, :suppress_project => suppress_project ) %>
<%= render(:partial => "todos/toggle_notes", :locals => { :item => todo }) if todo.notes? %>
<%= render(:partial => "todos/toggle_successors", :locals => { :item => todo }) unless todo.pending_successors.empty? %>
<%= render(:partial => "todos/toggle_notes", :object => todo) if todo.notes? %>
<%= render(:partial => "todos/toggle_successors", :object => todo) unless todo.pending_successors.empty? %>
</div>
</div>
<div id="<%= dom_id(todo, 'edit') %>" class="edit-form" style="display:none">

View file

@ -1,3 +1,4 @@
<% item = toggle_notes -%>
<%= link_to(image_tag( 'blank.png', :width=>'16', :height=>'16', :border=>'0' ), "#", {:class => 'show_notes', :title => 'Show notes'}) %>
<div class="todo_notes" id="<%= dom_id(item, 'notes') %>" style="display:none">

View file

@ -1,10 +1,10 @@
<% item = toggle_successors %>
<%= link_to(image_tag( 'blank.png', :width=>'16', :height=>'16', :border=>'0' ), "#", {:class => 'show_successors', :title => 'Show successors'}) %>
<div class="todo_successors" id="<%= dom_id(item, 'successors') %>">
<%= render :partial => "todos/successor",
:collection => item.pending_successors,
:locals => { :todo => item,
:parent_container_type => parent_container_type,
:locals => { :parent_container_type => parent_container_type,
:suppress_dependencies => true,
:predecessor => item }
%>

View file

@ -1 +1,4 @@
page.notify :error, @error_message || t('common.server_error'), 8.0
<%
# TODO: is this ever called?
-%>
TracksPages.page_notify('error', "<%=@error_message || t('common.server_error')%>", 8);

View file

@ -6,10 +6,11 @@
<% unless @done.nil? -%>
<%= render(
:partial => "todos/completed",
:locals => { :done => @done, :collapsible => true, :append_descriptor => nil }) -%>
:object => @done,
:locals => { :collapsible => true, :append_descriptor => nil }) -%>
<% end -%>
</div><!-- End of display_box -->
<div id="input_box">
<%= render :partial => "shared/add_new_item_form" %>
<%= render :template => "sidebar/sidebar.html.erb" %>
<%= render :file => "sidebar/sidebar.html.erb" %>
</div><!-- End of input box -->

View file

@ -1,5 +1,5 @@
<div id="display_box">
<div class="container context" <%= "style=\"display:none\"" unless @not_done_todos.empty? %> >
<div id="no_todos_in_tag_view" class="container context" <%= "style=\"display:none\"" unless @not_done_todos.empty? %> >
<h2><%= t('todos.no_actions_found')%></h2>
<div class="message"><p><%= t('todos.no_actions_with', :tag_name=>@tag_name) %></p></div>
</div>
@ -18,12 +18,12 @@
<% end -%>
<% unless @hidden_todos.nil? -%>
<%= render :partial => "todos/hidden", :locals => { :hidden => @hidden_todos, :collapsible => true, :append_descriptor => t('todos.tagged_with', :tag_name => @tag_name) } %>
<%= render :partial => "todos/hidden", :object => @hidden_todos, :locals => { :collapsible => true, :append_descriptor => t('todos.tagged_with', :tag_name => @tag_name) } %>
<% end -%>
<% unless @done.nil? -%>
<%= render :partial => "todos/completed",
:locals => { :done => @done, :collapsible => true, :append_descriptor => t('todos.tagged_with', :tag_name => @tag_name) } %>
<%= render :partial => "todos/completed", :object => @done,
:locals => { :collapsible => true, :append_descriptor => t('todos.tagged_with', :tag_name => @tag_name) } %>
<% end -%>
</div><!-- End of display_box -->

View file

@ -1,72 +1,133 @@
if @saved
page[@todo].remove
page.show "empty_"+@original_item_due_id if @old_due_empty
if @todo.completed?
<% if !@saved -%>
TracksPages.page_notify('error', "Could not mark this todo complete", 5);
<% else -%>
<% if @wants_redirect_after_complete -%>
redirect_after_complete();
<% else
animation = []
animation << "remove_todo"
if @todo.completed?
animation << "add_to_completed_container"
animation << "add_new_recurring_todo"
animation << "activate_pending_todos"
animation << "remove_source_container"
else
animation << "add_todo_to_context"
animation << "block_predecessors"
end -%>
<%= render_animation(animation) %>
TracksPages.set_page_badge(<%= @down_count %>);
<% end -%>
<% end -%>
# completed todos move from their context to the completed container
unless @prefs.hide_completed_actions?
page.insert_html :top, "completed_containeritems", :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => "completed" }
page.visual_effect :highlight, dom_id(@todo, 'line'), {'startcolor' => "'#99ff99'"}
page[empty_container_msg_div_id].show if @down_count == 0 && !empty_container_msg_div_id.nil?
page.show 'tickler-empty-nd' if source_view_is(:project) && @deferred_count == 0 && @pending_count == 0
page.hide 'empty-d' # If we've checked something as done, completed items can't be empty
end
# Activate pending todos that are successors of the completed
@pending_to_activate.each do |t|
logger.debug "#300: Removing #{t.description} from pending block and adding it to active"
page[t].remove if source_view_is(:project) or source_view_is(:tag)
page.insert_html :bottom, item_container_id(t), :partial => 'todos/todo', :locals => { :todo => t, :parent_container_type => parent_container_type }
page.visual_effect :highlight, dom_id(t, 'line'), {'startcolor' => "'#99ff99'"}
end
# remove container if empty
if @remaining_in_context == 0 && source_view_is_one_of(:todo, :tag)
page.visual_effect :fade, "c"+@todo.context.id.to_s, :duration => 0.4
end
function redirect_after_complete() {
redirect_to("<%= project_path(@todo.project) -%>");
}
if @original_item_was_deferred && source_view_is(:tag)
# we go from the deferred container to the completed container in tag view
# check for empty message
page['tickler-empty-nd'].show if @deferred_tag_count == 0
end
function remove_todo(next_steps) {
$('#<%= dom_id(@todo) %>').fadeOut(400, function() {
$('#<%= dom_id(@todo) %>').remove();
<%= show_empty_message_in_source_container -%>
next_steps.go();
});
}
# show new todo if the completed todo was recurring
function add_to_completed_container(next_steps) {
<% unless current_user.prefs.hide_completed_actions? -%>
$('#<%= item_container_id(@todo) %>').append(html_for_todo());
$("#empty-d").slideUp(100);
highlight_updated_todo(next_steps);
<% end -%>
}
function add_todo_to_context(next_steps) {
$('#<%= item_container_id(@todo) %>').append(html_for_todo());
$('#c<%= @todo.context_id %>').fadeIn(500, function() {
highlight_updated_todo(next_steps);
<%= show_empty_message_in_source_container -%>
});
}
function add_new_recurring_todo(next_steps) {
<% # show new todo if the completed todo was recurring
if @todo.from_recurring_todo?
unless @new_recurring_todo.nil? || @new_recurring_todo.deferred?
page.call "todoItems.ensureVisibleWithEffectAppear", item_container_id(@new_recurring_todo)
page.insert_html :bottom, item_container_id(@new_recurring_todo), :partial => 'todos/todo', :locals => { :todo => @new_recurring_todo, :parent_container_type => parent_container_type }
page.visual_effect :highlight, dom_id(@new_recurring_todo, 'line'), {'startcolor' => "'#99ff99'"}
else
if @todo.recurring_todo.todos.active.count == 0
page.notify :notice, t('todos.recurrence_completed'), 6.0 if @new_recurring_todo.nil?
end
unless @new_recurring_todo.nil? || @new_recurring_todo.deferred? -%>
$('#<%= item_container_id(@new_recurring_todo) %>').append(html_for_recurring_todo());
$('#c<%= @new_recurring_todo.context_id %>').fadeIn(500, function() {
highlight_updated_recurring_todo(next_steps);
});
<% else
if @todo.recurring_todo.todos.active.count == 0 && @new_recurring_todo.nil? -%>
TracksPages.page_notify('notice', "<%=t('todos.recurrence_completed')%>", 6);
<% end
end
end
else
# todo is activated from completed container
page.call "todoItems.ensureVisibleWithEffectAppear", item_container_id(@todo)
page.insert_html :bottom, item_container_id(@todo), :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => parent_container_type }
page.visual_effect :highlight, dom_id(@todo, 'line'), {'startcolor' => "'#99ff99'"}
page.show "empty-d" if @completed_count == 0
page.show "c"+@todo.context.id.to_s
page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil? # If we've checked something as undone, incomplete items can't be empty
# If active todos are successors of the reactivated todo they will be blocked
@active_to_block.each do |t|
logger.debug "#300: Block #{t.description} that are a successor of #{@todo.description}"
page[t].remove # Remove it from active
if source_view_is(:project) or source_view_is(:tag) # Insert it in deferred/pending block if existing
logger.debug "Insert #{t.description} in #{item_container_id(t)} block"
page.insert_html :bottom, item_container_id(t), :partial => 'todos/todo', :locals => { :todo => t, :parent_container_type => parent_container_type }
end
end
end
page.hide "status"
page.replace_html "badge_count", @down_count
if @todo.completed? && !@todo.project_id.nil? && @prefs.show_project_on_todo_done && !source_view_is(:project)
page.redirect_to project_path(@todo.project_id)
end
else
page.replace_html "status", content_tag("div", content_tag("h2", t(:todo_errors, :count => @todo.errors.count)) + content_tag("p", t('common.errors_with_fields')) + content_tag("ul", @todo.errors.each_full { |msg| content_tag("li", msg) }), "id" => "errorExplanation", "class" => "errorExplanation")
end
end -%>
}
<% if @new_recurring_todo # hide js if @new_recurring_todo is not there-%>
function highlight_updated_recurring_todo(next_steps) {
highlight_todo('#<%= dom_id(@new_recurring_todo)%>');
next_steps.go();
}
<% end -%>
function highlight_updated_todo(next_steps) {
highlight_todo('#<%= dom_id(@todo)%>');
next_steps.go();
}
function highlight_todo(id) {
$(id).effect('highlight', {}, 2000, function(){ });
}
function activate_pending_todos(next_steps) {
<% # Activate pending todos that are successors of the completed
if @saved && @pending_to_activate
# do not render the js in case of an error or if no todos to activate
@pending_to_activate.each do |t|
if source_view_is(:project) or source_view_is(:tag) -%>
$('#<%= dom_id(t) %>').fadeOut(400, function() {
$('#<%= dom_id(t) %>').remove();
next_steps.go();
});
<% end -%>
$('#<%= item_container_id(t) %>').append("<%= escape_javascript(render(:partial => 'todos/todo', :locals => { :todo => t, :parent_container_type => parent_container_type }))%>");
highlight_todo('#<%= dom_id(t)%>');
<% end -%>
<% end -%>
}
function block_predecessors(next_steps) {
<% # Activate pending todos that are successors of the completed
if @saved && @active_to_block
# do not render the js in case of an error or if no todos to block
@active_to_block.each do |t| %>
$('#<%= dom_id(t) %>').fadeOut(400, function() {
$('#<%= dom_id(t) %>').remove();
<% if source_view_is(:project) or source_view_is(:tag) # Insert it in deferred/pending block if existing -%>
$('#<%= item_container_id(t) %>').append("<%= escape_javascript(render(:partial => 'todos/todo', :locals => { :todo => t, :parent_container_type => parent_container_type }))%>");
highlight_todo('#<%= dom_id(t)%>');
<% end -%>
});
<% end -%>
next_steps.go();
<% end -%>
}
function remove_source_container(next_steps) {
<% if (@remaining_in_context == 0 && source_view_is_one_of(:todo, :tag))
# remove context with deleted todo
-%>
$('#c<%=@todo.context_id%>').fadeOut(1000, function() {
next_steps.go();
});
<% end %>
}
function html_for_todo() {
return "<%= @saved ? escape_javascript(render(:partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => "completed" })) : "" %>";
}
function html_for_recurring_todo() {
return "<%= @saved ? escape_javascript(render(:partial => 'todos/todo', :locals => { :todo => @new_recurring_todo, :parent_container_type => parent_container_type })) : "" %>";
}

View file

@ -15,11 +15,12 @@
end
animation << "hide_context" if update_needs_to_hide_context
animation << "highlight_updated_todo"
animation << "update_empty_tag_container" if source_view_is(:tag)
%>
<%= render_animation(animation) %>
TracksPages.page_notify('notice', '<%=@status_message%>', 5);
update_badge_count();
TracksPages.set_page_badge(<%= @down_count %>);
<% end %>
function remove_todo(next_steps) {
@ -65,7 +66,16 @@ function hide_context(next_steps) {
}
function highlight_updated_todo(next_steps) {
$('#<%= dom_id(@todo)%>').effect('highlight', {}, 2000, function(){ next_steps.go(); });
$('#<%= dom_id(@todo)%>').effect('highlight', {}, 2000, function(){ });
next_steps.go();
}
function update_empty_tag_container(next_steps) {
<% if @down_count==0 -%>
$('#no_todos_in_tag_view').slideDown(400, function(){ next_steps.go(); });
<% else -%>
$('#no_todos_in_tag_view').fadeOut(100, function(){ next_steps.go(); });
<% end -%>
}
function update_badge_count() {

View file

@ -21,6 +21,7 @@ config.action_controller.allow_forgery_protection = false
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
config.gem 'cucumber', :lib => false, :version => '=0.9.8' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails'))
config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.2' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails'))
config.gem 'database_cleaner', :lib => false, :version => '>=0.5.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/database_cleaner'))
config.gem 'webrat', :lib => false, :version => '>=0.7.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat'))

View file

@ -24,8 +24,6 @@ config.action_mailer.delivery_method = :test
# Unique cookies
config.action_controller.session = { :key => 'TracksSelenium' }
config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.2' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails'))
config.gem 'database_cleaner', :lib => false, :version => '>=0.5.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/database_cleaner'))
config.gem 'webrat', :lib => false, :version => '>=0.7.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat'))
config.gem 'selenium-client', :lib => false unless File.directory?(File.join(Rails.root, 'vendor/plugins/selenium-client'))
config.gem 'mongrel' # required by webrat for selenium

View file

@ -40,6 +40,5 @@ config.gem "ZenTest", :lib => "zentest", :version => ">=4.0.0"
config.gem "hpricot"
config.gem "hoe"
config.gem 'webrat', :lib => false, :version => '>=0.7.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat'))
config.gem 'rspec', :lib => false, :version => '=2.2.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec'))
config.gem 'rspec-rails', :lib => false, :version => '<2.2.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))
config.gem 'rspec-rails', :lib => false, :version => '<2.1.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))
config.gem "factory_girl", :lib => "factory_girl", :source => "http://gems.github.com"

View file

@ -94,6 +94,9 @@ Feature: Edit a project
Scenario: Moving the todo out of the tickler will move todo to active container
Given this scenario is pending
Scenario: Making all todos inactive will show empty message
Given this scenario is pending # empty message is in separate container
# Ticket #1043
@selenium @wip
Scenario: I can move a todo out of the current project

View file

@ -124,9 +124,8 @@ module LoginSystem
def get_current_user
if @user.nil? && session['user_id']
@user = User.find(session['user_id'], :include => [:preference])
@user = User.find(session['user_id'])
end
@prefs = @user.prefs unless @user.nil?
@user
end

View file

@ -361,6 +361,14 @@ var TodoItems = {
return false;
});
$(".item-container a.icon_defer_item").live('click', function(ev){
if ($(this).attr("x_defer_alert") == "true")
alert ($(this).attr("x_defer_date_after_due_date"));
else
put_with_ajax_and_block_element(this.href, $(this));
return false;
});
}
}

View file

@ -12,21 +12,21 @@ describe "/notes/_notes.rhtml" do
it "should render" do
pending "figure out how to mock or work with with UJS"
render :partial => "/notes/notes", :locals => {:notes => @note}
render :partial => "/notes/notes", :object => @note
response.should have_tag("div.note_footer")
end
it "should auto-link URLs" do
pending "figure out how to mock or work with with UJS"
@note.stub!(:body).and_return("http://www.google.com/")
render :partial => "/notes/notes", :locals => {:notes => @note}
render :partial => "/notes/notes", :object => @note
response.should have_tag("a[href=\"http://www.google.com/\"]")
end
it "should auto-link embedded URLs" do
pending "figure out how to mock or work with with UJS"
@note.stub!(:body).and_return("this is cool: http://www.google.com/")
render :partial => "/notes/notes", :locals => {:notes => @note}
render :partial => "/notes/notes", :object => @note
response.should have_tag("a[href=\"http://www.google.com/\"]")
end

View file

@ -9,25 +9,25 @@ describe "/todos/_toggle_notes.rhtml" do
end
it "should render" do
render :partial => "/todos/toggle_notes", :locals => {:item => @item}
render :partial => "/todos/toggle_notes", :object => @item
response.should have_tag("div.todo_notes")
end
it "should auto-link URLs" do
@item.stub!(:notes).and_return("http://www.google.com/")
render :partial => "/todos/toggle_notes", :locals => {:item => @item}
render :partial => "/todos/toggle_notes", :object => @item
response.should have_tag("a[href=\"http://www.google.com/\"]")
end
it "should auto-link embedded URLs" do
@item.stub!(:notes).and_return("this is cool: http://www.google.com/")
render :partial => "/todos/toggle_notes", :locals => {:item => @item}
render :partial => "/todos/toggle_notes", :object => @item
response.should have_tag("a[href=\"http://www.google.com/\"]")
end
it "should parse Textile URLs correctly" do
@item.stub!(:notes).and_return("\"link\":http://www.google.com/")
render :partial => "/todos/toggle_notes", :locals => {:item => @item}
render :partial => "/todos/toggle_notes", :object => @item
response.should have_tag("a[href=\"http://www.google.com/\"]")
end
end

View file

@ -33,7 +33,6 @@ class PreferencesControllerTest < ActionController::TestCase
get :edit
assert_response :success
assert_equal assigns['page_title'], "TRACKS::Edit Preferences"
assert_not_nil assigns['prefs']
assert_template 'preferences/edit'
end

View file

@ -16,7 +16,6 @@ class RecurringTodosControllerTest < ActionController::TestCase
def test_destroy_recurring_todo
login_as(:admin_user)
xhr :post, :destroy, :id => 1, :_source_view => 'todo'
assert_rjs :page, "recurring_todo_1", :remove
begin
rc = RecurringTodo.find(1)
rescue

View file

@ -61,16 +61,16 @@ class TodosControllerTest < ActionController::TestCase
def test_deferred_count_for_project_source_view
login_as(:admin_user)
xhr :post, :toggle_check, :id => 5, :_source_view => 'project'
assert_equal 1, assigns['deferred_count']
assert_equal 1, assigns['remaining_deferred_or_pending_count']
xhr :post, :toggle_check, :id => 15, :_source_view => 'project'
assert_equal 0, assigns['deferred_count']
assert_equal 0, assigns['remaining_deferred_or_pending_count']
end
def test_destroy_todo
login_as(:admin_user)
xhr :post, :destroy, :id => 1, :_source_view => 'todo'
assert_rjs :page, "todo_1", :remove
# #assert_rjs :replace_html, "badge-count", '9'
todo = Todo.find_by_id(1)
assert_nil todo
end
def test_create_todo
@ -91,7 +91,9 @@ class TodosControllerTest < ActionController::TestCase
def test_fail_to_create_todo_via_xml
login_as(:admin_user)
# #try to create with no context, which is not valid
put :create, :format => "xml", "request" => { "project_name"=>"Build a working time machine", "todo"=>{"notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"30/11/2006"}, "tag_list"=>"foo bar" }
put :create, :format => "xml", "request" => {
"project_name"=>"Build a working time machine",
"todo"=>{"notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"30/11/2006"}, "tag_list"=>"foo bar" }
assert_response 422
assert_xml_select "errors" do
assert_xml_select "error", "Context can't be blank"
@ -124,9 +126,9 @@ class TodosControllerTest < ActionController::TestCase
def test_update_todo_to_deferred_is_reflected_in_badge_count
login_as(:admin_user)
get :index
assert_equal 11, assigns['count']
assert_equal 10, assigns['count']
xhr :post, :update, :id => 1, :_source_view => 'todo', "context_name"=>"library", "project_name"=>"Make more money than Billy Gates", "todo"=>{"id"=>"1", "notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"30/11/2006", "show_from"=>"30/11/2030"}, "tag_list"=>"foo bar"
assert_equal 10, assigns['down_count']
assert_equal 9, assigns['down_count']
end
def test_update_todo
@ -311,7 +313,7 @@ class TodosControllerTest < ActionController::TestCase
def test_mobile_index_assigns_down_count
login_as(:admin_user)
get :index, { :format => "m" }
assert_equal 11, assigns['down_count']
assert_equal 10, assigns['down_count']
end
def test_mobile_create_action_creates_a_new_todo