diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 57095af9..587ee307 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -903,7 +903,7 @@ class TodosController < ApplicationController @target_context_count = current_user.projects.find(@todo.project_id).todos.active.count } from.calendar { - @target_context_count = count_old_due_empty(@new_due_id) + @target_context_count = @new_due_id.blank? ? 0 : count_old_due_empty(@new_due_id) } end @remaining_in_context = current_user.contexts.find(context_id).todos(true).active.not_hidden.count if !@remaining_in_context diff --git a/features/calendar.feature b/features/calendar.feature index 738a5f0d..165a4998 100644 --- a/features/calendar.feature +++ b/features/calendar.feature @@ -24,7 +24,8 @@ Feature: Show all due actions in a calendar view @selenium @wip Scenario: Clearing the due date of a todo will remove it from the calendar - When I submit a new action with description "a new next action" in the context "@calendar" + 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 edit the due date of "a new next action" to tomorrow And I go to the calendar page Then I should see "a new next action" diff --git a/features/step_definitions/todo_steps.rb b/features/step_definitions/todo_steps.rb index 218904e8..7b69de25 100644 --- a/features/step_definitions/todo_steps.rb +++ b/features/step_definitions/todo_steps.rb @@ -94,11 +94,14 @@ When /I change the (.*) field of "([^\"]*)" to "([^\"]*)"$/ do |field, todo_name todo = @current_user.todos.find_by_description(todo_name) todo.should_not be_nil - selenium.click("//img[@id='edit_icon_todo_#{todo.id}']", :wait_for => :ajax, :javascript_framework => :jquery) + #selenium.click("//img[@id='edit_icon_todo_#{todo.id}']", :wait_for => :ajax, :javascript_framework => :jquery) + open_edit_form_for(todo) selenium.type("css=form.edit_todo_form input[name=#{field}]", new_value) - selenium.click("css=button.positive", :wait_for => :ajax, :javascript_framework => :jquery) + #selenium.click("css=button.positive", :wait_for => :ajax, :javascript_framework => :jquery) + submit_edit_todo_form(todo) + # TODO: change to a wait_for - sleep(5) + sleep(1) end When /^I submit a new action with description "([^"]*)"$/ do |description| @@ -192,7 +195,7 @@ When /^I clear the due date of "([^"]*)"$/ do |action_description| todo = @current_user.todos.find_by_description(action_description) todo.should_not be_nil open_edit_form_for(todo) - selenium.click("//div[@id='edit_todo_#{todo.id}']//a[@id='due_x_todo_#{todo_id}']/img", :wait_for => :ajax, :javascript_framework => :jquery) + selenium.click("//div[@id='edit_todo_#{todo.id}']//a[@id='due_x_todo_#{todo.id}']/img", :wait_for => :ajax, :javascript_framework => :jquery) submit_edit_todo_form(todo) end diff --git a/features/support/world.rb b/features/support/world.rb index 9e5527a8..416fb682 100644 --- a/features/support/world.rb +++ b/features/support/world.rb @@ -5,6 +5,7 @@ module TracksStepHelper def submit_next_action_form selenium.click("xpath=//form[@id='todo-form-new-action']//button[@id='todo_new_action_submit']", :wait_for => :ajax, :javascript_framework => :jquery) + sleep(1) end def submit_new_context_form @@ -17,6 +18,9 @@ module TracksStepHelper def submit_edit_todo_form (todo) selenium.click("//div[@id='edit_todo_#{todo.id}']//button[@id='submit_todo_#{todo.id}']", :wait_for => :ajax, :javascript_framework => :jquery) + wait_for do + !selenium.is_element_present("//form[@id='form_todo_#{todo.id}']") + end end def format_date(date)