Add Selenium test for bug #776 and bug #775 and resolve both. Also fixed an unreported issue where deferring a todo by editing its show_from wouldn't hide an empty context.

This commit is contained in:
Eric Allen 2008-10-02 21:15:05 -04:00
parent 0a39e1ea7e
commit 397029dfc1
4 changed files with 40 additions and 6 deletions

View file

@ -221,7 +221,13 @@ class TodosController < ApplicationController
@saved = @todo.update_attributes params["todo"] @saved = @todo.update_attributes params["todo"]
@context_changed = @original_item_context_id != @todo.context_id @context_changed = @original_item_context_id != @todo.context_id
@todo_was_activated_from_deferred_state = @original_item_was_deferred && @todo.active? @todo_was_activated_from_deferred_state = @original_item_was_deferred && @todo.active?
determine_remaining_in_context_count(@original_item_context_id) if @context_changed
if @context_changed
determine_remaining_in_context_count(@original_item_context_id)
else
determine_remaining_in_context_count(@todo.context_id)
end
@project_changed = @original_item_project_id != @todo.project_id @project_changed = @original_item_project_id != @todo.project_id
if (@project_changed && !@original_item_project_id.nil?) then @remaining_undone_in_project = current_user.projects.find(@original_item_project_id).not_done_todo_count; end if (@project_changed && !@original_item_project_id.nil?) then @remaining_undone_in_project = current_user.projects.find(@original_item_project_id).not_done_todo_count; end
determine_down_count determine_down_count
@ -390,7 +396,9 @@ class TodosController < ApplicationController
@todo = Todo.find(params[:id]) @todo = Todo.find(params[:id])
@todo.show_from = (@todo.show_from || @todo.user.date) + numdays.days @todo.show_from = (@todo.show_from || @todo.user.date) + numdays.days
@saved = @todo.save @saved = @todo.save
determine_down_count
determine_remaining_in_context_count(@todo.context_id)
respond_to do |format| respond_to do |format|
format.html { redirect_to :back } format.html { redirect_to :back }
format.js {render :action => 'update'} format.js {render :action => 'update'}

View file

@ -16,10 +16,18 @@ if @saved
if (@remaining_in_context == 0) if (@remaining_in_context == 0)
# remove context container from page if empty # remove context container from page if empty
source_view do |from| if @context_changed
from.todo { page.visual_effect :fade, "c#{@original_item_context_id}", :duration => 0.4 } source_view do |from|
from.tag { page.visual_effect :fade, "c#{@original_item_context_id}", :duration => 0.4 } from.todo { page.visual_effect :fade, "c#{@original_item_context_id}", :duration => 0.4 }
from.context { page.show "c#{@original_item_context_id}empty-nd" } from.tag { page.visual_effect :fade, "c#{@original_item_context_id}", :duration => 0.4 }
from.context { page.show "c#{@original_item_context_id}empty-nd" }
end
else
source_view do |from|
from.todo { page.visual_effect :fade, item_container_id(@todo), :duration => 0.4 }
from.tag { page.visual_effect :fade, item_container_id(@todo), :duration => 0.4 }
from.context { page.show "c#{@original_item_context_id}empty-nd" }
end
end end
end end

View file

@ -0,0 +1,10 @@
setup :fixtures => :all
login :as => 'admin'
open "/"
click "edit_icon_todo_5"
wait_for_element_present "show_from_todo_5"
type "show_from_todo_5", "1/1/2030"
click "css=#submit_todo_5"
wait_for_element_not_present "todo_5"
assert_text 'badge_count', '9'
wait_for_not_visible "c5"

View file

@ -0,0 +1,8 @@
setup :fixtures => :all
login :as => 'admin'
open "/"
wait_for_element_present '//div[@id="line_todo_5"]//img[@alt="Defer_1"]/..'
click '//div[@id="line_todo_5"]//img[@alt="Defer_1"]/..'
wait_for_element_not_present "todo_5"
assert_text 'badge_count', '9'
wait_for_not_visible "c5"