fix some failing cucumber tests

This commit is contained in:
Reinier Balt 2014-01-09 11:18:33 +01:00
parent def136374c
commit 3b673f0838
12 changed files with 41 additions and 33 deletions

View file

@ -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)

View file

@ -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'

View file

@ -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

View file

@ -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

View file

@ -10,9 +10,11 @@
<div class="container">
<div class="paginate_header"><%= will_paginate @done, paginate_options %></div>
<h2><%= t('todos.all_completed') %></h2>
<% if @done.empty? -%>
<div id="all-done-empty-nd" style="<%= @done.empty? ? 'display:block' : 'display:none'%>">
<div class="message"><p><%= t('todos.no_completed_actions') %></p></div>
<% else -%>
</div>
<% if !@done.empty? -%>
<%= render :partial => "todos/todo", :collection => @done, :locals => { :parent_container_type => "completed", :suppress_context => false, :suppress_project => false } %>
<% end -%>
</div>

View file

@ -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 <grouping>
@ -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"

View file

@ -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

View file

@ -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|

View file

@ -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)

View file

@ -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 <page>
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 <next page>
Then I should see "todo 1" <where>
@ -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"

View file

@ -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