fix corner case that were failing the cucumber tests. On the calendar page at the end of the month, a todo may occur twice on the page. This was not taken into account for update an destroy

This commit is contained in:
Reinier Balt 2011-04-30 17:57:36 +02:00
parent 0ccf42d08c
commit 7f27a6e2bd
6 changed files with 36 additions and 15 deletions

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
*.tmproj *.tmproj
.dotest .dotest
/.emacs-project /.emacs-project
/.redcar
config/database.yml config/database.yml
config/site.yml config/site.yml
config/deploy.rb config/deploy.rb

View file

@ -625,7 +625,7 @@ class TodosController < ApplicationController
due_this_week_date = Time.zone.now.end_of_week due_this_week_date = Time.zone.now.end_of_week
due_next_week_date = due_this_week_date + 7.days due_next_week_date = due_this_week_date + 7.days
due_this_month_date = Time.zone.now.end_of_month due_this_month_date = Time.zone.now.end_of_month
@due_today = current_user.todos.not_completed.find(:all, @due_today = current_user.todos.not_completed.find(:all,
:include => [:taggings, :tags], :include => [:taggings, :tags],
:conditions => ['todos.due <= ?', due_today_date], :conditions => ['todos.due <= ?', due_today_date],
@ -646,7 +646,7 @@ class TodosController < ApplicationController
:include => [:taggings, :tags], :include => [:taggings, :tags],
:conditions => ['todos.due > ?', due_this_month_date], :conditions => ['todos.due > ?', due_this_month_date],
:order => "due") :order => "due")
@count = current_user.todos.not_completed.are_due.count @count = current_user.todos.not_completed.are_due.count
respond_to do |format| respond_to do |format|
@ -1278,6 +1278,16 @@ class TodosController < ApplicationController
return false if context_name.blank? return false if context_name.blank?
true true
end end
def determine_non_uniq_todo
# for calendar view. TODO: unused
all_list_uniq_ids = (@due_today.map(&:id) + @due_this_week.map(&:id) +
@due_next_week.map(&:id) + @due_this_month.map(&:id) + @due_after_this_month.map(&:id)).uniq
all_list_count = @due_today.count + @due_this_week.count +
@due_next_week.count + @due_this_month.count + @due_after_this_month.count
return !( all_list_uniq_ids.length == all_list_count )
end
class FindConditionBuilder class FindConditionBuilder

View file

@ -32,19 +32,24 @@ function show_empty_messages() {
function remove_todo_from_page() { function remove_todo_from_page() {
<% if (@remaining_in_context == 0) && update_needs_to_hide_context <% if (@remaining_in_context == 0) && update_needs_to_hide_context
# remove context with deleted todo # remove context with deleted todo
-%> -%>
$('#c<%=@todo.context_id%>').fadeOut(400, function() { $('#c<%=@todo.context_id%>').fadeOut(400, function() {
$('#<%=dom_id(@todo)%>').remove(); $('#<%=dom_id(@todo)%>').remove();
}); });
<%= show_empty_message_in_source_container -%> <%= show_empty_message_in_source_container -%>
<% else <% else
# remove only the todo # remove only the todo
-%> -%>
<%= show_empty_message_in_source_container %> <%= show_empty_message_in_source_container %>
$('#<%=dom_id(@todo)%>').slideUp(400, function() { $('#<%=dom_id(@todo)%>').slideUp(400, function() {
$('#<%=dom_id(@todo)%>').remove(); $('#<%=dom_id(@todo)%>').remove();
}); <% if source_view_is :calendar
# in calendar view it is possible to have a todo twice on the page
-%>
$('#<%=dom_id(@todo)%>').remove();
<% end %>
});
<% end -%> <% end -%>
} }

View file

@ -27,6 +27,11 @@
function remove_todo(next_steps) { function remove_todo(next_steps) {
$('#<%= dom_id(@todo) %>').fadeOut(400, function() { $('#<%= dom_id(@todo) %>').fadeOut(400, function() {
$('#<%= dom_id(@todo) %>').remove(); $('#<%= dom_id(@todo) %>').remove();
<% if source_view_is :calendar
# in calendar view it is possible to have a todo twice on the page
-%>
$('#<%= dom_id(@todo) %>').remove();
<% end %>
<%= show_empty_message_in_source_container -%> <%= show_empty_message_in_source_container -%>
next_steps.go(); next_steps.go();
}); });

View file

@ -327,7 +327,7 @@ nl:
show_tomorrow: Toon morgen show_tomorrow: Toon morgen
calendar: calendar:
get_in_ical_format: Ontvang deze agenda in iCal-formaat get_in_ical_format: Ontvang deze agenda in iCal-formaat
due_next_week: Deadline deze week due_next_week: Deadline volgende week
due_this_week: Deadline in rest van deze week due_this_week: Deadline in rest van deze week
no_actions_due_next_week: Geen acties met deadline in volgende week no_actions_due_next_week: Geen acties met deadline in volgende week
due_today: Deadline vandaag due_today: Deadline vandaag

View file

@ -22,7 +22,7 @@ Feature: Show all due actions in a calendar view
Then the badge should show 1 Then the badge should show 1
And I should see "a new next action" And I should see "a new next action"
@selenium @selenium
Scenario: Clearing the due date of a todo will remove it from the calendar Scenario: Clearing the due date of a todo will remove it from the calendar
When I go to the home page When I go to the home page
And I submit a new action with description "a new next action" in the context "@calendar" And I submit a new action with description "a new next action" in the context "@calendar"
@ -32,7 +32,7 @@ Feature: Show all due actions in a calendar view
When I clear the due date of "a new next action" When I clear the due date of "a new next action"
Then I should not see "a new next action" Then I should not see "a new next action"
@selenium @selenium
Scenario: Marking a todo complete will remove it from the calendar Scenario: Marking a todo complete will remove it from the calendar
Given I have a todo "a new next action" in the context "@calendar" which is due tomorrow Given I have a todo "a new next action" in the context "@calendar" which is due tomorrow
When I go to the calendar page When I go to the calendar page