fix #922. You can now mark a todo complete from the tickler. Also fixed some small aasm corner cases found by this change

This commit is contained in:
Reinier Balt 2011-08-18 17:15:00 +02:00
parent 367907eab2
commit 07b05d01f7
16 changed files with 276 additions and 147 deletions

View file

@ -122,4 +122,50 @@ 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 project container for "dependencies"
And I should see "test 1" in project container for "dependencies"
@selenium
Scenario Outline: Marking a successor as complete will update predecessor
Given I have a context called "@pc"
And I have a project "dependencies" that has the following todos
| description | context | completed | tags |
| test 1 | @pc | no | bla |
| test 2 | @pc | no | bla |
| test 3 | @pc | yes | bla |
When I go to the <page>
And I drag "test 1" to "test 2"
When I expand the dependencies of "test 2"
Then I should see "test 1" within the dependencies of "test 2"
And I should see "test 1" in the deferred container
When I mark "test 1" as complete
Then I should see that "test 2" does not have dependencies
And I should see "test 1" in the completed container
Scenarios:
| page |
| "dependencies" project |
| tag page for "bla" |
@selenium
Scenario Outline: Marking a successor as active will update predecessor
Given I have a context called "@pc"
And I have a project "dependencies" that has the following todos
| description | context | completed | tags |
| test 1 | @pc | no | bla |
| test 2 | @pc | no | bla |
| test 3 | @pc | yes | bla |
When I go to the <page>
And I drag "test 1" to "test 2"
Then I should see "test 1" in the deferred container
When I mark "test 1" as complete
And I should see "test 1" in the completed container
And I should see that "test 2" does not have dependencies
When I mark the complete todo "test 1" active
Then I should not see "test 1" in the completed container
And I should see "test 1" in the deferred container
And I should see "test 1" within the dependencies of "test 2"
Scenarios:
| page |
| "dependencies" project |
| tag page for "bla" |

View file

@ -35,6 +35,7 @@ Feature: Edit a next action from every page
And I should see "delete me" in the context container for "@home"
When I mark "delete me" as complete
Then I should not see the container for context "@home"
And I should see "delete me" in the completed container
When I mark "delete me" as uncompleted
Then I should see the container for context "@home"
When I edit the context of "delete me" to "@pc"

View file

@ -1,3 +1,5 @@
####### Context #######
Then /^I should not see the context "([^"]*)"$/ do |context_name|
context = @current_user.contexts.find_by_name(context_name)
context.should_not be_nil
@ -23,10 +25,11 @@ Then /^I should see the container for context "([^"]*)"$/ do |context_name|
context = @current_user.contexts.find_by_name(context_name)
context.should_not be_nil
xpath = "xpath=//div[@id='c#{context.id}']"
xpath = "//div[@id='c#{context.id}']"
selenium.wait_for_element(xpath, :timeout_in_seconds => 5)
selenium.is_visible(xpath).should be_true
wait_for :timeout => 5 do
selenium.is_visible(xpath)
end
end
Then /^the container for the context "([^"]*)" should be visible$/ do |context_name|
@ -60,6 +63,8 @@ Then /^I should not see "([^"]*)" in the context container for "([^"]*)"$/ do |t
end
end
####### Deferred #######
Then /^I should see "([^"]*)" in the deferred container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
@ -71,6 +76,19 @@ Then /^I should see "([^"]*)" in the deferred container$/ do |todo_description|
end
end
Then /^I should not see "([^"]*)" in the deferred container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='tickler']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
!selenium.is_element_present(xpath)
end
end
####### Project #######
Then /^I should see "([^"]*)" in the action container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
@ -98,51 +116,6 @@ Then /^I should not see "([^"]*)" in the project container of "([^"]*)"$/ do |to
end
end
Then /^I should see "([^"]*)" in the completed container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='completed_container']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
Then /^I should not see "([^"]*)" in the deferred container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='tickler']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
!selenium.is_element_present(xpath)
end
end
Then /^I should see "([^"]*)" in the hidden container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='hidden']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
Then /^I should see "([^"]*)" in the due next month container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='due_after_this_month']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
Then /^I should see "([^"]*)" in project container for "([^"]*)"$/ do |todo_description, project_name|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
@ -156,6 +129,60 @@ Then /^I should see "([^"]*)" in project container for "([^"]*)"$/ do |todo_desc
selenium.is_visible(xpath).should be_true
end
####### Completed #######
Then /^I should see "([^"]*)" in the completed container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='completed_container']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
Then /^I should not see "([^"]*)" in the completed container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='completed_container']//div[@id='line_todo_#{todo.id}']"
if selenium.is_element_present(xpath)
wait_for :timeout => 5 do
!selenium.is_element_present(xpath)
end
end
end
####### Hidden #######
Then /^I should see "([^"]*)" in the hidden container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='hidden']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
####### Calendar #######
Then /^I should see "([^"]*)" in the due next month container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='due_after_this_month']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
####### Repeat patterns #######
Then /^I should see "([^"]*)" in the active recurring todos container$/ do |repeat_pattern|
repeat = @current_user.recurring_todos.find_by_description(repeat_pattern)

View file

@ -114,3 +114,16 @@ Then /^I should not see "([^"]*)" within the dependencies of "([^"]*)"$/ do |suc
!selenium.is_element_present(xpath)
end
end
Then /^I should see that "([^"]*)" does not have dependencies$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
dependencies_icon = "//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img"
if selenium.is_element_present(dependencies_icon)
wait_for :timeout => 5 do
!selenium.is_element_present(dependencies_icon)
end
end
end

View file

@ -6,17 +6,7 @@ When /^I mark "([^"]*)" as complete$/ do |action_description|
check "mark_complete_#{todo.id}"
todo_container = "fail" # fail this test if @source_view is wrong
todo_container = "p#{todo.project_id}items" if @source_view=="project"
todo_container = "c#{todo.context_id}items" if @source_view=="context" || @source_view=="todos" || @source_view=="tag"
todo_container = "tickler_container" if @source_view=="stats"
# container should be there
selenium.is_element_present("//div[@id='#{todo_container}']").should be_true
wait_for :timeout => 5 do
!selenium.is_element_present("//div[@id='#{todo_container}']//div[@id='line_todo_#{todo.id}']")
end
wait_for_ajax
end
When /^I mark "([^"]*)" as uncompleted$/ do |action_description|
@ -25,19 +15,7 @@ When /^I mark "([^"]*)" as uncompleted$/ do |action_description|
check "mark_complete_#{todo.id}"
todo_container = "fail" # fail this test if @source_view is wrong
todo_container = "p#{todo.project_id}items" if @source_view=="project"
todo_container = "c#{todo.context_id}items" if @source_view=="context" || @source_view=="todos" || @source_view=="tag"
todo_container.should_not == "fail" unless @source_view=="done"
unless @source_view=="done"
wait_for :timeout => 5 do
selenium.is_element_present("//div[@id='#{todo_container}']//div[@id='line_todo_#{todo.id}']")
end
else
wait_for_ajax
end
wait_for_ajax
end
When /^I mark the complete todo "([^"]*)" active$/ do |action_description|

View file

@ -60,7 +60,6 @@ Then /^I should see ([0-9]+) todos$/ do |count|
end
Then /^there should not be an error$/ do
sleep(5)
# form should be gone and thus no errors visible
wait_for :timeout => 5 do
!selenium.is_visible("edit_todo_#{@dep_todo.id}")
@ -72,7 +71,11 @@ Then /^I should see the todo "([^\"]*)"$/ do |todo_description|
end
Then /^I should not see the todo "([^\"]*)"$/ do |todo_description|
selenium.is_element_present("//span[.=\"#{todo_description}\"]").should be_false
if selenium.is_element_present("//span[.=\"#{todo_description}\"]")
wait_for :timeout => 5 do
!selenium.is_element_present("//span[.=\"#{todo_description}\"]")
end
end
end
Then /^the number of actions should be (\d+)$/ do |count|

View file

@ -74,6 +74,7 @@ module NavigationHelpers
when /the integrations page/
integrations_path(options)
when /the tickler page/
@source_view = "deferred"
tickler_path(options)
when /the export page/
data_path(options)

View file

@ -57,3 +57,12 @@ Feature: Manage deferred todos
When I go to the tickler page
Then I should see "not yet now"
And I should not see "now is a good time"
@selenium
Scenario: I can mark an action complete from the tickler
Given I have a deferred todo "not yet now"
When I go to the tickler page
And I mark "not yet now" as complete
Then I should not see "not yet now"
When I go to the done page
Then I should see "not yet now"