From 6e5057138de7df7aa7dbe1317e22529512c06a2d Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Wed, 14 Jul 2010 23:34:47 +0200 Subject: [PATCH] add cucumber scenarios for adding multiple next actions --- app/helpers/todos_helper.rb | 3 + features/shared_add_new_todo.feature | 88 +++++++++++++++++-------- features/step_definitions/todo_steps.rb | 14 ++++ 3 files changed, 79 insertions(+), 26 deletions(-) diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index b8ea341e..32d1bc84 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -251,11 +251,14 @@ module TodosHelper return false if source_view_is(:context) && (@todo.project.hidden? || @todo.project.completed?) end + return false if (source_view_is(:tag) && !@todo.tags.include?(@tag_name)) + return true if source_view_is(:deferred) && @todo.deferred? return true if source_view_is(:project) && @todo.project.hidden? && @todo.project_hidden? return true if source_view_is(:project) && @todo.deferred? return true if !source_view_is(:deferred) && @todo.active? return true if source_view_is(:project) && @todo.pending? + return true if source_view_is(:tag) && @todo.pending? return false end diff --git a/features/shared_add_new_todo.feature b/features/shared_add_new_todo.feature index 6164469e..9955e63e 100644 --- a/features/shared_add_new_todo.feature +++ b/features/shared_add_new_todo.feature @@ -9,8 +9,8 @@ Feature: Add new next action from every page | login | password | is_admin | | testuser | secret | false | And I have logged in as "testuser" with password "secret" - And I have a context called "test" - And I have a project "test" with 1 todos + And I have a context called "test context" + And I have a project "test project" with 1 todos @selenium Scenario Outline: I can hide the input form for single next action on a page @@ -20,12 +20,12 @@ Feature: Add new next action from every page Then the single action form should not be visible Scenarios: - | action | page | - | go to | home page | - | go to | tickler page | - | visit | project page for "test"| - | visit | context page for "test"| - | visit | tag page for "starred" | + | action | page | + | go to | home page | + | go to | tickler page | + | visit | project page for "test project"| + | visit | context page for "test context"| + | visit | tag page for "starred" | @selenium Scenario Outline: I can hide the input form for multiple next actions @@ -38,12 +38,12 @@ Feature: Add new next action from every page And the multiple action form should not be visible Scenarios: - | action | page | - | go to | home page | - | go to | tickler page | - | visit | project page for "test"| - | visit | context page for "test"| - | visit | tag page for "starred" | + | action | page | + | go to | home page | + | go to | tickler page | + | visit | project page for "test project"| + | visit | context page for "test context"| + | visit | tag page for "starred" | @selenium Scenario Outline: I can hide the input form and then choose both input forms @@ -58,12 +58,12 @@ Feature: Add new next action from every page And the multiple action form should not be visible Scenarios: - | action | page | - | go to | home page | - | go to | tickler page | - | visit | project page for "test"| - | visit | context page for "test"| - | visit | tag page for "starred" | + | action | page | + | go to | home page | + | go to | tickler page | + | visit | project page for "test project"| + | visit | context page for "test context"| + | visit | tag page for "starred" | @selenium Scenario Outline: I can switch forms for single next action to multiple next actions @@ -77,9 +77,45 @@ Feature: Add new next action from every page And the multiple action form should not be visible Scenarios: - | action | page | - | go to | home page | - | go to | tickler page | - | visit | project page for "test"| - | visit | context page for "test"| - | visit | tag page for "starred" | + | action | page | + | go to | home page | + | go to | tickler page | + | visit | project page for "test project"| + | visit | context page for "test context"| + | visit | tag page for "starred" | + + @selenium + Scenario Outline: I can add a todo from several pages + When I the + And I submit a new action with description "a new next action" + Then I should "a new next action" + + Scenarios: + | action | page | see | + | go to | home page | see | + | go to | tickler page | not see| + | visit | project page for "test project"| see | + | visit | context page for "test context"| see | + | visit | tag page for "starred" | not see| + + @selenium + Scenario Outline: I can add multiple todos from several pages + When I the + And I follow "Add multiple next actions" + And I submit multiple actions with using + """ + one new next action + another new next action + """ + Then I should "one new next action" + And I should "another new next action" + And the badge should show + And the number of actions should be + + Scenarios: + | action | page | see | badge | count | + | go to | home page | see | 3 | 3 | + | go to | tickler page | not see| 0 | 3 | + | visit | project page for "test project"| see | 3 | 3 | + | visit | context page for "test context"| see | 2 | 3 | + | visit | tag page for "starred" | not see| 0 | 3 | \ No newline at end of file diff --git a/features/step_definitions/todo_steps.rb b/features/step_definitions/todo_steps.rb index 98831bca..e1b183f7 100644 --- a/features/step_definitions/todo_steps.rb +++ b/features/step_definitions/todo_steps.rb @@ -66,6 +66,16 @@ When /I change the (.*) field of "([^\"]*)" to "([^\"]*)"$/ do |field, todo_name sleep(5) end +When /^I submit a new action with description "([^"]*)"$/ do |description| + fill_in "todo[description]", :with => description + selenium.click("xpath=//form[@id='todo-form-new-action']//button[@id='todo_new_action_submit']", :wait_for => :ajax, :javascript_framework => :jquery) +end + +When /^I submit multiple actions with using$/ do |multiple_actions| + fill_in "todo[multiple_todos]", :with => multiple_actions + selenium.click("xpath=//form[@id='todo-form-multi-new-action']//button[@id='todo_multi_new_action_submit']", :wait_for => :ajax, :javascript_framework => :jquery) +end + Then /^the dependencies of "(.*)" should include "(.*)"$/ do |child_name, parent_name| parent = @current_user.todos.find_by_description(parent_name) parent.should_not be_nil @@ -96,3 +106,7 @@ end Then /^I should not see the todo "([^\"]*)"$/ do |todo_description| selenium.is_element_present("//span[.=\"#{todo_description}\"]").should be_false end + +Then /^the number of actions should be (\d+)$/ do |count| + @current_user.todos.count.should == count.to_i +end