fix failing tests

This commit is contained in:
Reinier Balt 2013-06-11 15:36:27 +02:00
parent 07de6a8358
commit 7084c11263
12 changed files with 61 additions and 45 deletions

View file

@ -512,18 +512,18 @@ module TodosHelper
end
def update_needs_to_hide_container
if source_view_is(:tag)
if source_view_is_one_of(:tag, :context, :project)
return @remaining_in_context == 0 && (
todo_moved_out_of_container ||
(@todo_hidden_state_changed && @todo.hidden?) ||
@todo_was_deferred_from_active_state ||
@tag_was_removed ||
@todo_was_destroyed ||
(@todo.completed? && !(@original_item_was_deferred || @original_item_was_hidden))
(@todo.completed? && !(@original_item_was_deferred || @original_item_was_hidden || @original_item_was_pending))
)
end
return false if source_view_is_one_of(:project, :calendar, :done, :context)
return false if source_view_is_one_of(:calendar, :done)
return @remaining_in_context == 0
end
@ -599,7 +599,7 @@ module TodosHelper
end
def todo_container_empty_id(todo)
raise Exception.new, "no todo set in TodosHelper::todo_container_empty_id. You probably not assign @original_item" if !todo
raise Exception.new, "no todo set in TodosHelper::todo_container_empty_id. You probably did not assign @original_item" if !todo
@group_view_by == "project" ? project_container_empty_id(todo) : context_container_empty_id(todo)
end
@ -609,8 +609,7 @@ module TodosHelper
return "#{@new_due_id}_container" if source_view_is :calendar
return "deferred_pending_container" if !source_view_is(:todo) && (todo.deferred? || todo.pending?)
return "completed_container" if todo.completed?
return "p#{todo.project_id}" if source_view_is :project
return project_container_id(todo) if source_view_is_one_of(:todo, :tag) && @group_view_by == 'project'
return project_container_id(todo) if source_view_is_one_of(:todo, :tag, :project, :context) && @group_view_by == 'project'
return context_container_id(todo)
end
@ -620,7 +619,7 @@ module TodosHelper
source_view do |page|
page.project {
return "deferred_pending_container-empty-d" if empty_criteria_met
return project_container_empty_id(todo)
return todo_container_empty_id(todo)
}
page.tag {
return "deferred_pending_container-empty-d" if empty_criteria_met
@ -633,7 +632,7 @@ module TodosHelper
}
page.context {
return "deferred_pending_container-empty-d" if empty_criteria_met
return context_container_empty_id(todo)
return todo_container_empty_id(todo)
}
page.todo {
return todo_container_empty_id(todo)

View file

@ -5,7 +5,11 @@
show_empty_containers = (@group_view_by == 'context')
-%>
<div id="display_box">
<%= empty_message_holder("not_done_project", @not_done_todos.empty?) %>
<%= show_grouped_todos({:collapsible => false, :show_empty_containers => show_empty_containers, :parent_container_type => 'context'}) %>
<% if @group_view_by == 'project' -%>
<%= show_todos_without_project(@todos_without_project, {:collapsible => false, :parent_container_type => 'context', :title_param => @context.name}) -%>
<% end -%>

View file

@ -9,14 +9,15 @@
# force project view so one empty container will be shown with an empty message
@group_view_by = 'project'
end
show_empty_containers = (@group_view_by == 'project')
-%>
<div id="display_box">
<%= project_next_prev %>
<%= render :partial => "project_settings_container", :locals => {:project => @project} %>
<%= show_grouped_todos({:collapsible => false, :show_empty_containers => show_empty_containers, :parent_container_type => 'project' }) %>
<%= empty_message_holder("not_done_context", @not_done_todos.empty?) %>
<%= show_grouped_todos({:collapsible => false, :show_empty_containers => false, :parent_container_type => 'project' }) %>
<%= show_deferred_pending_todos(@deferred_todos, @pending_todos, deferred_pending_options) %>

View file

@ -15,7 +15,7 @@
animation << "add_todo_to_container" unless source_view_is(:done)
animation << "block_predecessors"
end
animation << "update_empty_container" if source_view_is_one_of(:tag, :todo, :deferred)
animation << "update_empty_container" if source_view_is_one_of(:tag, :todo, :deferred, :project, :context)
animation << "regenerate_predecessor_family"
else
animation << "replace_todo"
@ -63,7 +63,6 @@ function replace_todo(next_steps) {
}
function add_todo_to_container(next_steps) {
// <%= @group_view_by %>
$('#<%= item_container_id(@todo) %>_items').append(html_for_todo());
<% if should_make_context_visible -%>
$('#<%= item_container_id(@todo) %>').slideDown(500, function() {
@ -120,7 +119,7 @@ function highlight_updated_todo(next_steps) {
function activate_pending_todos(next_steps) {
<% # Activate pending todos that are successors of the completed
if @saved && @pending_to_activate
if @pending_to_activate
# do not render the js in case of an error or if no todos to activate
@pending_to_activate.each do |t|
html = escape_javascript(render(:partial => t, :locals => { :parent_container_type => parent_container_type }))
@ -173,7 +172,7 @@ end
function html_for_recurring_todo() {
<%-
js = @saved && @new_recurring_todo ? escape_javascript(render(:partial => @new_recurring_todo, :locals => { :parent_container_type => parent_container_type })) : ""
js = @new_recurring_todo ? escape_javascript(render(:partial => @new_recurring_todo, :locals => { :parent_container_type => parent_container_type })) : ""
-%>
return "<%= js %>";
}
@ -181,7 +180,7 @@ function html_for_recurring_todo() {
function html_for_todo() {
<%-
js = ""
if @saved && !source_view_is(:done)
if !source_view_is(:done)
js = escape_javascript(render(
:partial => @todo,
:locals => {

View file

@ -20,7 +20,7 @@
end
animation << "hide_container" if update_needs_to_hide_container
animation << "highlight_updated_todo"
animation << "update_empty_container" if source_view_is_one_of(:tag, :todo, :deferred)
animation << "update_empty_container" if source_view_is_one_of(:tag, :todo, :deferred, :project, :context)
animation << "update_predecessors"
%>
TracksPages.page_notify('notice', '<%=escape_javascript @status_message%>', 5);

View file

@ -435,6 +435,8 @@ en:
completed: Currently there are no completed actions
title: No actions found
not_done_with_tag: "Currently there are no incomplete actions with the tag '%{param}'"
not_done_project: Currently there are no incomplete actions in this project
not_done_context: Currently there are no incomplete actions in this context
completed_recurring: Currently there are no completed recurring todos
not_done: Currently there are no incomplete actions
project: Currently there are no incomplete actions in this project

View file

@ -68,10 +68,10 @@ Feature: dependencies
And "test 2" depends on "test 1"
When I go to the "dependencies" project
Then I should see "test 2" in the deferred container
And I should see "test 1" in the action container
And I should see "test 1" in the context container for "@pc"
When I mark "test 1" as complete
Then I should see "test 1" in the completed container
And I should see "test 2" in the action container
And I should see "test 2" in the context container for "@pc"
And I should not see "test 2" in the deferred container
And I should see empty message for deferred todos of project
@ -86,9 +86,9 @@ Feature: dependencies
And "test 2" depends on "test 1"
When I go to the "dependencies" project
Then I should see "test 2" in the deferred container
And I should see "test 1" in the action container
And I should see "test 1" in the context container for "@pc"
When I delete the action "test 1"
Then I should see "test 2" in the action container
Then I should see "test 2" in the context container for "@pc"
And I should not see "test 2" in the deferred container
And I should see empty message for deferred todos of project
@ -122,7 +122,7 @@ Feature: dependencies
When I go to the "dependencies" project
And I drag "test 1" to "test 3"
Then I should see an error flash message saying "Cannot add this action as a dependency to a completed action!"
And I should see "test 1" in the project container of "dependencies"
And I should see "test 1" in the context container for "@pc"
@javascript
Scenario Outline: Marking a successor as complete will update predecessor
@ -171,5 +171,6 @@ Feature: dependencies
Scenarios:
| page | grouping |
| "dependencies" project | project |
| "dependencies" project | context |
| tag page for "bla" | context |
| tag page for "bla" | project |

View file

@ -55,7 +55,7 @@ Feature: Edit a next action from every page
@javascript @wip
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 on webkit though
# 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>
@ -77,6 +77,7 @@ Feature: Edit a next action from every page
@javascript
Scenario Outline: Deleting the last todo in container will show empty message # only project, context, tag, not todo
Given I have a context called "@home"
And I have selected the view for group by <grouping>
And I have a project "my project" that has the following todos
| context | description | tags |
| @home | first action | test, bla |
@ -90,10 +91,13 @@ Feature: Edit a next action from every page
Then I should see empty message for todos of <page type>
Scenarios:
| page | page type |
| "my project" project | project |
| context page for "@home" | context |
| tag page for "bla" | tag |
| page | page type | grouping |
| "my project" project | project | project |
| "my project" project | project | context |
| context page for "@home" | context | context |
| context page for "@home" | context | project |
| tag page for "bla" | tag | context |
| tag page for "bla" | tag | project |
@javascript
Scenario Outline: I can mark an active todo complete and it will update empty messages
@ -156,7 +160,7 @@ Feature: Edit a next action from every page
| home page | home | project | container for project "visible project" |
@javascript
Scenario Outline: I can mark a completed todo active and it will update empty messages for pages without context containers
Scenario Outline: I can mark a completed todo active and it will update empty messages for pages without hideable containers
Given I have a completed todo with description "visible todo" in project "visible project" with tags "starred" in the context "visible context"
When I go to the <page>
Then I should see empty message for todos of <page type>

View file

@ -123,7 +123,7 @@ Feature: Edit a project
Scenario: Moving the todo to the tickler will move todo to tickler container and update empty messages
Given I have a project "test" with 1 todos
When I go to the "test" project
Then I should see "todo 1" in the action container
Then I should see "todo 1" in the context container for "Context A"
And I should see empty message for deferred todos of project
And I should see empty message for completed todos of project
When I defer "todo 1" for 1 day

View file

@ -97,7 +97,9 @@ Feature: Add new next action from every page
| tickler page | context | not see |
| tickler page | project | not see |
| "test project" project | context | see |
| "test project" project | project | see |
| context page for "test context" | context | see |
| context page for "test context" | project | see |
| tag page for "starred" | context | see |
| tag page for "starred" | project | see |
@ -124,7 +126,9 @@ Feature: Add new next action from every page
| tickler page | not see | 0 | 3 | context |
| tickler page | not see | 0 | 3 | project |
| "testing" project | see | 3 | 3 | context |
| "testing" project | see | 3 | 3 | project |
| context page for "test context" | see | 2 | 3 | context |
| context page for "test context" | see | 2 | 3 | project |
| tag page for "starred" | see | 2 | 3 | context |
| tag page for "starred" | see | 2 | 3 | project |
@ -199,9 +203,13 @@ Feature: Add new next action from every page
| tickler page | context | not see | not see |
| tickler page | project | not see | not see |
| "visible project" project | project | not see | see |
| "visible project" project | context | not see | see |
| "hidden project" project | project | see | not see |
| "hidden project" project | context | see | not see |
| context page for "visible context" | context | not see | see |
| context page for "visible context" | project | not see | see |
| context page for "other context" | context | not see | not see |
| context page for "other context" | project | not see | not see |
| tag page for "starred" | context | not see | not see |
| tag page for "starred" | project | not see | not see |
| tag page for "test" | context | see | see |

View file

@ -91,7 +91,6 @@ Then(/^I should (not see|see) "([^"]*)" in the (completed|done today|done this w
id = 'completed_rest_of_month_container' if container == 'done this month'
css = "div##{id} div#line_todo_#{find_todo(todo_description).id}"
page.should have_css(css)
check_css_visibility(visible, css)
end
@ -138,9 +137,8 @@ end
Then /^I should (see|not see) empty message for (done today|done this week|done this month|completed todos|deferred todos|todos) (of done actions|of context|of project|of home|of tag)/ do |visible, state, type|
css = "error: wrong state"
css = "div#c#{@context.id}-empty-d" if state == "todos" && type == "of context"
css = "div#p#{@project.id}-empty-d" if state == "todos" && type == "of project"
css = "div#no_todos_in_view" if state == "todos" && (type == "of home" || type == "of tag")
css = "div#c#{@context.id}-empty-d" if state == "todos"
css = "div#no_todos_in_view" if state == "todos" && ["of home", "of tag", "of context", "of project"].include?(type)
css = "div#completed_today_container" if state == "done today"
css = "div#completed_rest_of_week_container" if state == "done this week"
css = "div#completed_rest_of_month_container" if state == "done this month"

View file

@ -70,9 +70,9 @@ Given /^I have ([0-9]+) todos$/ do |count|
end
Given /^I have a todo with description "([^"]*)" in project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)"$/ do |action_description, project_name, tags, context_name|
context = @current_user.contexts.where(:name => context_name).first_or_create
project = @current_user.projects.where(:name => project_name).first_or_create
@todo = @current_user.todos.create!(:context_id => context.id, :project_id => project.id, :description => action_description)
@context = @current_user.contexts.where(:name => context_name).first_or_create
@project = @current_user.projects.where(:name => project_name).first_or_create
@todo = @current_user.todos.create!(:context_id => @context.id, :project_id => @project.id, :description => action_description)
@todo.tag_with(tags)
@todo.save
end