From 3b673f083807b94f61f92e113c3477a690db8e29 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Thu, 9 Jan 2014 11:18:33 +0100 Subject: [PATCH] fix some failing cucumber tests --- Gemfile.lock | 4 ++-- app/controllers/application_controller.rb | 6 +++--- app/controllers/todos_controller.rb | 11 +++++++---- app/helpers/todos_helper.rb | 3 ++- app/views/todos/all_done.html.erb | 6 ++++-- features/calendar.feature | 2 +- features/edit_a_todo.feature | 6 ------ features/step_definitions/project_list_steps.rb | 8 ++++++++ features/step_definitions/todo_steps.rb | 2 -- features/support/tracks_step_helper.rb | 6 ++++-- features/view_done.feature | 12 ++++++------ lib/tracks/done_todos.rb | 8 ++++---- 12 files changed, 41 insertions(+), 33 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 23f3476c..58a6b34d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,7 +55,7 @@ GEM cache_digests (0.3.1) actionpack (>= 3.2) thread_safe - capybara (2.2.0) + capybara (2.2.1) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) @@ -122,7 +122,7 @@ GEM protected_attributes (1.0.5) activemodel (>= 4.0.1, < 5.0) rack (1.5.2) - rack-mini-profiler (0.1.31) + rack-mini-profiler (0.9.0) rack (>= 1.1.3) rack-test (0.6.2) rack (>= 1.0) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a5694db6..bd50b0bd 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -269,7 +269,7 @@ class ApplicationController < ActionController::Base def all_done_todos_for(object) object_name = object.class.name.downcase # context or project - @source_view = object_name + @source_view = "all_done" @page_title = t("#{object_name.pluralize}.all_completed_tasks_title", "#{object_name}_name".to_sym => object.name) @done = object.todos.completed.reorder('completed_at DESC').includes(Todo::DEFAULT_INCLUDES). @@ -280,11 +280,11 @@ class ApplicationController < ActionController::Base def done_todos_for(object) object_name = object.class.name.downcase # context or project - @source_view = object_name + @source_view = "done" eval("@#{object_name} = object") @page_title = t("#{object_name.pluralize}.completed_tasks_title", "#{object_name}_name".to_sym => object.name) - @done_today, @done_rest_of_week, @done_rest_of_month = DoneTodos.done_todos_for_container(object) + @done_today, @done_rest_of_week, @done_rest_of_month = DoneTodos.done_todos_for_container(object.todos) @count = @done_today.size + @done_rest_of_week.size + @done_rest_of_month.size render :template => 'todos/done' diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index e903c218..5c8d1be3 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -522,7 +522,7 @@ class TodosController < ApplicationController @source_view = 'done' @page_title = t('todos.completed_tasks_title') - @done_today, @done_rest_of_week, @done_rest_of_month = DoneTodos.done_todos_for_container(current_user) + @done_today, @done_rest_of_week, @done_rest_of_month = DoneTodos.done_todos_for_container(current_user.todos) @count = @done_today.size + @done_rest_of_week.size + @done_rest_of_month.size respond_to do |format| @@ -672,7 +672,7 @@ class TodosController < ApplicationController end def done_by_tag_setup - @source_view = params['_source_view'] || 'tag' + @source_view = params['_source_view'] || 'done' @tag_name = sanitize(params[:name]) # sanitize to prevent XSS vunerability! @page_title = t('todos.all_completed_tagged_page_title', :tag_name => @tag_name) @tag = Tag.where(:name => @tag_name).first_or_create @@ -762,7 +762,7 @@ class TodosController < ApplicationController @items = get_not_completed_for_predecessor(current_user, @todo.id) unless !@items.empty? else # New todo - TODO: Filter on current project in project view - @items = get_not_complete_for_predecessor(current_user) + @items = get_not_completed_for_predecessor(current_user) end render :inline => format_dependencies_as_json_for_auto_complete(@items) end @@ -1003,7 +1003,10 @@ end @target_context_count = actions_in_target.count } from.done { - @remaining_in_context = DoneTodos.remaining_in_container(current_user, @original_completed_period) + @remaining_in_context = DoneTodos.remaining_in_container(current_user.todos, @original_completed_period) + } + from.all_done { + @remaining_in_context = current_user.todos.completed.count } end end diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index a5eeb3bc..07455c80 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -523,7 +523,7 @@ module TodosHelper ) end - return false if source_view_is_one_of(:calendar, :done) + return false if source_view_is_one_of(:calendar, :done, :all_done) return @remaining_in_context == 0 end @@ -692,6 +692,7 @@ module TodosHelper } page.todo { container_id = context_container_empty_id(@original_item) if @remaining_in_context == 0 } page.done { container_id = "completed_#{@original_completed_period}_container-empty-d" if @remaining_in_context == 0 } + page.all_done { container_id = "all-done-empty-nd" if @remaining_in_context == 0 } end return container_id.blank? ? "" : "$(\"##{container_id}\").slideDown(100);".html_safe end diff --git a/app/views/todos/all_done.html.erb b/app/views/todos/all_done.html.erb index d55c05c1..46c32642 100644 --- a/app/views/todos/all_done.html.erb +++ b/app/views/todos/all_done.html.erb @@ -10,9 +10,11 @@
<%= will_paginate @done, paginate_options %>

<%= t('todos.all_completed') %>

- <% if @done.empty? -%> +

<%= t('todos.no_completed_actions') %>

- <% else -%> +
+ + <% if !@done.empty? -%> <%= render :partial => "todos/todo", :collection => @done, :locals => { :parent_container_type => "completed", :suppress_context => false, :suppress_project => false } %> <% end -%>
diff --git a/features/calendar.feature b/features/calendar.feature index 42af0d32..c58d623d 100644 --- a/features/calendar.feature +++ b/features/calendar.feature @@ -41,7 +41,7 @@ Feature: Show all due actions in a calendar view When I clear the due date of "something new" Then I should not see the todo "something new" - @javascript + @javascript Scenario: Deleting a todo will remove it from the calendar Given I have a todo "something new" in the context "@calendar" which is due tomorrow When I go to the calendar page diff --git a/features/edit_a_todo.feature b/features/edit_a_todo.feature index c3e5bda1..fb60b9aa 100644 --- a/features/edit_a_todo.feature +++ b/features/edit_a_todo.feature @@ -54,8 +54,6 @@ Feature: Edit a next action from every page @javascript Scenario Outline: Changing container of the todo in that container will hide it - # this script fails on https://code.google.com/p/selenium/issues/detail?id=3075 for selenium-webdriver > 2.14. - # and selenium-webdriver < 2.20 fails on firefox 11 :-( So @wip for now. This may work with webkit though Given I have a todo "delete me" in the context "@home" in the project "do it" And I have a project "go for it" And I have selected the view for group by @@ -249,8 +247,6 @@ Feature: Edit a next action from every page @javascript Scenario: I can defer a todo - # this script fails on https://code.google.com/p/selenium/issues/detail?id=3075 for selenium-webdriver > 2.14. - # and selenium-webdriver < 2.20 fails on firefox 11 :-( So @wip for now. This will work on webkit though When I go to the home page And I submit a new action with description "start later" in the context "@pc" And I defer "start later" for 1 day @@ -260,8 +256,6 @@ Feature: Edit a next action from every page @javascript Scenario: I can make a project from a todo - # this script fails on https://code.google.com/p/selenium/issues/detail?id=3075 for selenium-webdriver > 2.14. - # and selenium-webdriver < 2.20 fails on firefox 11 :-( So @wip for now. This will work on webkit though When I go to the home page And I submit a new action with description "buy mediacenter" in the context "@pc" And I make a project of "buy mediacenter" diff --git a/features/step_definitions/project_list_steps.rb b/features/step_definitions/project_list_steps.rb index 571d8464..22ca8c23 100644 --- a/features/step_definitions/project_list_steps.rb +++ b/features/step_definitions/project_list_steps.rb @@ -73,6 +73,14 @@ Then /^I should not see a project named "([^"]*)"$/ do |project_name| step "I should see that a project named \"#{project_name}\" is not present" end +Then(/^I should not see the project "(.*?)"$/) do |project_name| + project = @current_user.projects.where(:name => project_name).first + project.should_not be_nil + + project_xpath = "//div[@id='project_#{project.id}']" + page.should_not have_xpath(project_xpath) +end + Then /^the project "([^"]*)" should be above the project "([^"]*)"$/ do |project_high, project_low| project_list_find_index(project_high).should < project_list_find_index(project_low) end diff --git a/features/step_definitions/todo_steps.rb b/features/step_definitions/todo_steps.rb index 8e11b886..a574d6d2 100644 --- a/features/step_definitions/todo_steps.rb +++ b/features/step_definitions/todo_steps.rb @@ -15,8 +15,6 @@ When /^I delete the action "([^"]*)"$/ do |action_description| get_confirm_text.should == "Are you sure that you want to delete the action '#{todo.description}'?" wait_for_ajax - # commented out: the notice is gone if you want to check for it - # wait_for_animations_to_end end When /^I delete the todo "([^"]*)"$/ do |action_description| diff --git a/features/support/tracks_step_helper.rb b/features/support/tracks_step_helper.rb index b9bbd3e1..14518010 100644 --- a/features/support/tracks_step_helper.rb +++ b/features/support/tracks_step_helper.rb @@ -115,10 +115,12 @@ module TracksStepHelper end def open_submenu_for(todo) + wait_for_animations_to_end + 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 - sleep 0.1 + arrow = page.find(submenu_arrow, :match => :first) + arrow.click submenu_css = "div#line_todo_#{todo.id} ul#ultodo_#{todo.id}" submenu = page.find(submenu_css) diff --git a/features/view_done.feature b/features/view_done.feature index f62f6e06..701fb938 100644 --- a/features/view_done.feature +++ b/features/view_done.feature @@ -136,9 +136,9 @@ Feature: Show done @javascript Scenario Outline: I can toggle a todo active from the done pages When I go to the - Then I should see "todo 1" + Then I should see the todo "todo 1" When I mark the completed todo "todo 1" active - Then I should not see "todo 1" + Then I should not see the todo "todo 1" When I go to the Then I should see "todo 1" @@ -163,13 +163,13 @@ Feature: Show done And I should see "todo 2" in the done this week container And I should see "todo 3" in the done this month container When I mark the completed todo "todo 1" active - Then I should not see "todo 1" + Then I should not see the todo "todo 1" And I should see empty message for done today of done actions When I mark the completed todo "todo 2" active - Then I should not see "todo 2" + Then I should not see the todo "todo 2" And I should see empty message for done this week of done actions When I mark the completed todo "todo 3" active - Then I should not see "todo 3" + Then I should not see the todo "todo 3" And I should see empty message for done this month of done actions @javascript @@ -196,7 +196,7 @@ Feature: Show done When I go to the done projects page Then I should see "completed project" When I edit the project state of "completed project" to "active" - Then I should not see "completed project" + Then I should not see the project "completed project" When I go to the projects page Then I should see "completed project" diff --git a/lib/tracks/done_todos.rb b/lib/tracks/done_todos.rb index 179f6661..413a9e08 100644 --- a/lib/tracks/done_todos.rb +++ b/lib/tracks/done_todos.rb @@ -1,8 +1,8 @@ class DoneTodos - def self.done_todos_for_container(user) - completed_todos = user.todos.completed + def self.done_todos_for_container(todos) + completed_todos = todos.completed return done_today(completed_todos), done_rest_of_week(completed_todos), done_rest_of_month(completed_todos) end @@ -29,8 +29,8 @@ class DoneTodos return nil end - def self.remaining_in_container(user, period) - count = self.send("done_#{period}", user.todos.completed, {}).count + def self.remaining_in_container(todos, period) + count = self.send("done_#{period}", todos.completed, {}).count return nil if period.nil? return count end