diff --git a/features/step_definitions/todo_edit_steps.rb b/features/step_definitions/todo_edit_steps.rb index 8371b134..17077f70 100644 --- a/features/step_definitions/todo_edit_steps.rb +++ b/features/step_definitions/todo_edit_steps.rb @@ -134,7 +134,9 @@ When /^I clear the due date of "([^"]*)"$/ do |action_description| todo.should_not be_nil open_edit_form_for(todo) - within "div#edit_todo_#{todo.id}" do + # use all()[0] to get the first todo. This is for calendar page where you can have + # de same todo more than once + within all("div#edit_todo_#{todo.id}")[0] do find("a#due_x_todo_#{todo.id}").click wait_until do find("input#due_todo_#{todo.id}").value == "" @@ -169,9 +171,9 @@ When /^I defer "([^"]*)" for 1 day$/ do |action_description| todo = @current_user.todos.where(:description => action_description).first todo.should_not be_nil - open_submenu_for(todo) - page.should have_css("a#defer_1_todo_#{todo.id}", :visible=>true) - click_link "defer_1_todo_#{todo.id}" + open_submenu_for(todo) do + click_link "defer_1_todo_#{todo.id}" + end wait_for_ajax wait_for_animations_to_end @@ -192,9 +194,9 @@ When /^I make a project of "([^"]*)"$/ do |action_description| todo = @current_user.todos.where(:description => action_description).first todo.should_not be_nil - open_submenu_for(todo) - page.should have_css("a#to_project_todo_#{todo.id}", :visible=>true) - click_link "to_project_todo_#{todo.id}" + open_submenu_for(todo) do + click_link "to_project_todo_#{todo.id}" + end page.should have_no_css("div#line_todo_#{todo.id}") wait_for_ajax diff --git a/features/step_definitions/todo_steps.rb b/features/step_definitions/todo_steps.rb index 4e4178ab..1f471f73 100644 --- a/features/step_definitions/todo_steps.rb +++ b/features/step_definitions/todo_steps.rb @@ -9,8 +9,9 @@ When /^I delete the action "([^"]*)"$/ do |action_description| todo.should_not be_nil handle_js_confirm do - open_submenu_for(todo) - click_link "delete_todo_#{todo.id}" + open_submenu_for(todo) do + click_link "delete_todo_#{todo.id}" + end end get_confirm_text.should == "Are you sure that you want to delete the action '#{todo.description}'?" diff --git a/features/support/world.rb b/features/support/world.rb index 6f36b7c4..e099ff6e 100644 --- a/features/support/world.rb +++ b/features/support/world.rb @@ -107,9 +107,14 @@ module TracksStepHelper submenu_arrow = "div#line_todo_#{todo.id} img.todo-submenu" page.should have_css(submenu_arrow, :visible=>true) - page.find(submenu_arrow).click + # pick the first because calendar page could have the same todo more than once + page.all(submenu_arrow)[0].click page.should have_css("div#line_todo_#{todo.id} ul#ultodo_#{todo.id}", :visible => true) + + within all("div#line_todo_#{todo.id} ul#ultodo_#{todo.id}")[0] do + yield + end end def context_list_find_index(context_name)