get some further scenarios for adding todos to several pages

one is still failing, will get to that
This commit is contained in:
Reinier Balt 2011-01-08 19:50:19 +01:00
parent ab2e51a51a
commit 8cbe077784
8 changed files with 118 additions and 32 deletions

View file

@ -51,6 +51,7 @@ class TodosController < ApplicationController
def create
@source_view = params['_source_view'] || 'todo'
@default_context = current_user.contexts.find_by_name(params['default_context_name'])
@default_project = current_user.projects.find_by_name(params['default_project_name'])
@tag_name = params['_tag_name']

View file

@ -205,21 +205,23 @@ module TodosHelper
end
def should_show_new_item
return false if source_view_is(:todo) && @todo.hidden?
return false if source_view_is(:context) && @todo.hidden? && !@todo.context.hidden?
return true if source_view_is(:tag) && (
(@todo.pending? && @todo.tags.include?(@tag_name)) ||
@todo.tags.include?(@tag_name) ||
(@todo.starred? && @tag_name == Todo::STARRED_TAG_NAME))
return false if (source_view_is(:context) && !(@todo.context_id==@default_context.id) )
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(:project) && @todo.pending?
return true if !source_view_is(:deferred) && @todo.active?
source_view do |page|
page.todo { return !@todo.hidden? }
page.deferred { return @todo.deferred? || @todo.pending? }
page.context {
return @todo.context_id==@default_context.id && (!@todo.hidden? && !@todo.context.hidden?)
}
page.tag {
return ( (@todo.pending? && @todo.has_tag?(@tag_name)) ||
(@todo.has_tag?(@tag_name)) ||
(@todo.starred? && @tag_name == Todo::STARRED_TAG_NAME)
)
}
page.project {
return (@todo.active? && @todo.project && @todo.project.id == @default_project.id) ||
(@todo.project.hidden? && @todo.project_hidden?) || @todo.deferred? || @todo.pending?
}
end
return false
end

View file

@ -24,7 +24,7 @@ Feature: Add new next action from every page
| go to | tickler page |
| visit | project page for "test project" |
| visit | context page for "test context" |
| visit | tag page for "starred" |
| go to | tag page for "starred" |
@selenium
Scenario Outline: I can hide the input form for multiple next actions
@ -42,7 +42,7 @@ Feature: Add new next action from every page
| go to | tickler page |
| visit | project page for "test project" |
| visit | context page for "test context" |
| visit | tag page for "starred" |
| go to | tag page for "starred" |
@selenium
Scenario Outline: I can hide the input form and then choose both input forms
@ -62,7 +62,7 @@ Feature: Add new next action from every page
| go to | tickler page |
| visit | project page for "test project" |
| visit | context page for "test context" |
| visit | tag page for "starred" |
| go to | tag page for "starred" |
@selenium
Scenario Outline: I can switch forms for single next action to multiple next actions
@ -81,7 +81,7 @@ Feature: Add new next action from every page
| go to | tickler page |
| visit | project page for "test project" |
| visit | context page for "test context" |
| visit | tag page for "starred" |
| go to | tag page for "starred" |
@selenium
Scenario Outline: I can add a todo from several pages
@ -95,7 +95,7 @@ Feature: Add new next action from every page
| 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 |
| go to | tag page for "starred" | not see |
@selenium
Scenario Outline: I can add multiple todos from several pages
@ -117,7 +117,7 @@ Feature: Add new next action from every page
| 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 |
| go to | tag page for "starred" | not see | 0 | 3 |
Scenario: Adding a todo to another project does not show the todo
Given this is a pending scenario
@ -125,7 +125,7 @@ Feature: Add new next action from every page
Scenario: Adding a todo to a hidden project does not show the todo
Given this is a pending scenario
@selenium @wip
@selenium
Scenario Outline: Adding a todo with a new context shows the new context
When I <action> the <page>
And I submit a new <todo> with description "do at new context" and the tags "starred" in the context "New"
@ -139,13 +139,49 @@ Feature: Add new next action from every page
| go to | tickler page | deferred action | 1 | be visible |
| visit | project page for "test project" | action | 2 | not be visible |
| visit | context page for "test context" | action | 1 | not be visible |
| visit | tag page for "starred" | action | 1 | be visible |
| go to | tag page for "starred" | action | 1 | be visible |
Scenario: Adding a todo to a hidden context does not show the todo
Given this is a pending scenario
@selenium @wip
Scenario Outline: Adding a todo to a hidden project does not show the todo
Given I have a hidden project called "hidden project"
And I have a project called "visible project"
And I have a context called "visible context"
And I have a context called "other context"
When I go to the <page>
And I submit a new action with description "hidden todo" to project "hidden project" with tags "test" in the context "visible context"
Then I should <see_hidden> "hidden todo"
When I submit a new action with description "visible todo" to project "visible project" with tags "test" in the context "visible context"
Then I should <see_visible> "visible todo"
Scenario: Adding a todo to an empty container hides the empty message
Given this is a pending scenario
Scenarios:
| page | see_hidden | see_visible |
| home page | not see | see |
| tickler page | not see | not see |
| "visible project" project | not see | see |
| "hidden project" project | see | not see |
| context page for "visible context" | not see | see |
| context page for "other context" | not see | not see |
| tag page for "starred" | not see | not see |
| tag page for "test" | see | see |
@selenium
Scenario: Adding a todo to a hidden context does not show the todo
Given I have a context called "visible context"
And I have a hidden context called "hidden context"
When I go to the home page
And I submit a new action with description "a new todo" in the context "visible context"
Then I should see "a new todo"
When I submit a new action with description "another new todo" in the context "hidden context"
Then I should not see "another new todo"
@selenium
Scenario: Adding a todo to an empty container hides the empty message # TODO: make outline
And I have a context called "visible context"
When I go to the tag page for "test"
Then I should see "Currently there are no incomplete actions with the tag 'test'"
When I submit a new action with description "a new todo" and the tags "test" in the context "visible context"
Then I should see "a new todo"
And I should not see "Currently there are no incomplete actions with the tag 'bla'"
Scenario: Adding a dependency to a todo updated the successor
Given this is a pending scenario

View file

@ -34,6 +34,11 @@ Given /^I have no projects$/ do
Project.delete_all
end
Given /^I have a hidden project called "([^"]*)"$/ do |project_name|
@project = @current_user.projects.create!(:name => project_name)
@project.hide!
end
When /^I visit the "([^\"]*)" project$/ do |project_name|
@project = Project.find_by_name(project_name)
@project.should_not be_nil

View file

@ -90,24 +90,54 @@ end
When /^I submit a new action with description "([^"]*)"$/ do |description|
fill_in "todo[description]", :with => description
submit_next_action_form
selenium.wait_for :wait_for => :ajax, :javascript_framework => :jquery
end
When /^I submit a new action with description "([^"]*)" and the tags "([^"]*)" in the context "([^"]*)"$/ do |description, tags, context_name|
fill_in "todo[description]", :with => description
fill_in "tag_list", :with => tags
js="$('#todo_context_name').val('');"
selenium.get_eval "(function() {with(this) {#{js}}}).call(selenium.browserbot.getCurrentWindow());"
# fill_in does not seem to work when the field is prefilled with something. Empty the field first
clear_context_name_from_next_action_form
fill_in "todo_context_name", :with => context_name
submit_next_action_form
selenium.wait_for :wait_for => :ajax, :javascript_framework => :jquery
end
When /^I submit a new deferred action with description "([^"]*)" and the tags "([^"]*)" in the context "([^"]*)"$/ do |description, tags, context_name|
fill_in "todo[description]", :with => description
clear_context_name_from_next_action_form
fill_in "context_name", :with => context_name
fill_in "tag_list", :with => tags
fill_in "todo[show_from]", :with => format_date(@current_user.time + 1.week)
submit_next_action_form
selenium.wait_for :wait_for => :ajax, :javascript_framework => :jquery
end
When /^I submit a new action with description "([^"]*)" to project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)"$/ do |description, project_name, tags, context_name|
fill_in "todo[description]", :with => description
clear_project_name_from_next_action_form
clear_context_name_from_next_action_form
fill_in "todo_project_name", :with => project_name
fill_in "context_name", :with => context_name
fill_in "tag_list", :with => tags
submit_next_action_form
selenium.wait_for :wait_for => :ajax, :javascript_framework => :jquery
end
When /^I submit a new action with description "([^"]*)" in the context "([^"]*)"$/ do |description, context_name|
fill_in "todo[description]", :with => description
clear_context_name_from_next_action_form
fill_in "context_name", :with => context_name
submit_next_action_form
selenium.wait_for :wait_for => :ajax, :javascript_framework => :jquery
end
When /^I submit multiple actions with using$/ do |multiple_actions|

View file

@ -1,3 +0,0 @@
When /^I visit the tag page for "([^"]*)"$/ do |tag_name|
visit "/todos/tag/#{tag_name}"
end

View file

@ -44,11 +44,15 @@ module NavigationHelpers
feeds_path
when /the context page for "([^\"]*)" for user "([^\"]*)"/i
context_path(User.find_by_login($2).contexts.find_by_name($1))
when /the context page for "([^\"]*)"/i
context_path(@current_user.contexts.find_by_name($1))
when /the "([^\"]*)" project for user "([^\"]*)"/i
project_path(User.find_by_login($2).projects.find_by_name($1))
when /the "([^\"]*)" project/i
@project = @current_user.projects.find_by_name($1)
project_path(@project)
when /the tag page for "([^"]*)"/i
tag_path($1)
# Add more mappings here.
# Here is an example that pulls values out of the Regexp:

View file

@ -20,6 +20,17 @@ module TracksStepHelper
return date ? date.in_time_zone(@current_user.prefs.time_zone).strftime("#{@current_user.prefs.date_format}") : ''
end
def execute_javascript(js)
selenium.get_eval "(function() {with(this) {#{js}}}).call(selenium.browserbot.getCurrentWindow());"
end
def clear_context_name_from_next_action_form
execute_javascript("$('#todo_context_name').val('');")
end
def clear_project_name_from_next_action_form
execute_javascript("$('#todo_project_name').val('');")
end
end