diff --git a/features/step_definitions/todo_steps.rb b/features/step_definitions/todo_steps.rb index 2db27f0a..8e11b886 100644 --- a/features/step_definitions/todo_steps.rb +++ b/features/step_definitions/todo_steps.rb @@ -5,8 +5,7 @@ end ####### DELETE ####### When /^I delete the action "([^"]*)"$/ do |action_description| - todo = @current_user.todos.where(:description => action_description).first - todo.should_not be_nil + todo = find_todo(action_description) handle_js_confirm do open_submenu_for(todo) do diff --git a/features/support/tracks_step_helper.rb b/features/support/tracks_step_helper.rb index 19e167c2..57d9a0d7 100644 --- a/features/support/tracks_step_helper.rb +++ b/features/support/tracks_step_helper.rb @@ -74,14 +74,14 @@ module TracksStepHelper end def context_list_find_index(context_name) - div_id = "context_#{@current_user.contexts.where(:name => context_name).first.id}" + div_id = "context_#{find_context(context_name).id}" contexts = page.all("div.context").map { |x| x[:id] } return contexts.find_index(div_id) end def project_list_find_index(project_name) # TODO: refactor with context_list_find_index - div_id = "project_#{@current_user.projects.where(:name => project_name).first.id}" + div_id = "project_#{find_project(project_name).id}" project = page.all("div.project").map { |x| x[:id] } return project.find_index(div_id) end @@ -91,10 +91,6 @@ module TracksStepHelper return date ? date.in_time_zone(@current_user.prefs.time_zone).strftime("#{@current_user.prefs.date_format}") : '' end - def execute_javascript(js) - page.execute_script(js) - end - def context_drag_and_drop(drag_id, delta) sortable_css = "div.ui-sortable div#container_context_#{drag_id}" execute_javascript("$('#{sortable_css}').simulateDragSortable({move: #{delta}, handle: '.grip'});") @@ -103,12 +99,13 @@ module TracksStepHelper def open_submenu_for(todo) submenu_arrow = "div#line_todo_#{todo.id} img.todo-submenu" page.should have_css(submenu_arrow, :visible=>true) - page.find(submenu_arrow, :match => :first).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 + submenu_css = "div#line_todo_#{todo.id} ul#ultodo_#{todo.id}" + submenu = page.find(submenu_css) + wait_until { submenu.visible? } + + within submenu do yield end end @@ -125,5 +122,9 @@ module TracksStepHelper def get_confirm_text page.evaluate_script "window.confirmMsg" end + + def execute_javascript(js) + page.execute_script(js) + end end \ No newline at end of file diff --git a/features/view_done.feature b/features/view_done.feature index 5f184879..f62f6e06 100644 --- a/features/view_done.feature +++ b/features/view_done.feature @@ -157,7 +157,7 @@ Feature: Show done Scenario: Activating the last todo will show empty message Given the date is "2013-03-11" And I have a completed todo with description "todo 2" in context "@pc" completed 1 days ago - And I have a completed todo with description "todo 3" in context "@pc" completed 8 days ago + And I have a completed todo with description "todo 3" in context "@pc" completed 7 days ago When I go to the done actions page Then I should see "todo 1" in the done today container And I should see "todo 2" in the done this week container