From f544c80fbcbe7517d7f1fcadae5773d226c7ded4 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Thu, 11 Aug 2011 17:13:01 +0200 Subject: [PATCH] add some pending cucumber scenarios and fix a small bug it uncovered --- app/controllers/todos_controller.rb | 19 ++++++- app/helpers/todos_helper.rb | 54 +++++++++---------- app/views/todos/destroy.js.erb | 25 ++++++--- features/context_edit.feature | 48 +++++++++++++++-- features/dependencies.feature | 18 ++++++- features/edit_a_todo.feature | 35 ++++++++++-- features/project_edit.feature | 6 +-- features/shared_add_new_todo.feature | 10 +++- features/step_definitions/container_steps.rb | 21 +++++++- .../step_definitions/dependencies_steps.rb | 3 +- features/step_definitions/project_steps.rb | 14 ++--- .../step_definitions/todo_create_steps.rb | 24 +++++++++ features/step_definitions/todo_edit_steps.rb | 12 +++-- features/step_definitions/todo_steps.rb | 38 ++++++++++++- features/view_done.feature | 28 +++++++++- 15 files changed, 290 insertions(+), 65 deletions(-) diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index d962c753..cc2223b9 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -437,6 +437,11 @@ class TodosController < ApplicationController @todo_was_destroyed_from_pending_state = @todo.pending? @todo_was_destroyed_from_deferred_or_pending_state = @todo_was_destroyed_from_deferred_state || @todo_was_destroyed_from_pending_state + @uncompleted_predecessors = [] + @todo.uncompleted_predecessors.each do |predecessor| + @uncompleted_predecessors << predecessor + end + # activate successors if they only depend on this todo activated_successor_count = 0 @pending_to_activate = [] @@ -961,7 +966,16 @@ class TodosController < ApplicationController @down_count = current_user.todos.active.not_hidden.count end from.context do - @down_count = current_user.contexts.find(@todo.context_id).todos.not_completed.count(:all) + context_id = @original_item_context_id || @todo.context_id + todos = current_user.contexts.find(context_id).todos.not_completed + + if @todo.context.hide? + # include hidden todos + @down_count = todos.count(:all) + else + # exclude hidden_todos + @down_count = todos.not_hidden.count(:all) + end end from.project do unless @todo.project_id == nil @@ -1352,6 +1366,9 @@ class TodosController < ApplicationController @tag_name = params['_tag_name'] @tag_was_removed = !@todo.has_tag?(@tag_name) end + page.context do + @todo_should_be_hidden = @todo_hidden_state_changed && @todo.hidden? + end end end diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 98947bfe..c1ac9a53 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -18,7 +18,7 @@ module TodosHelper def remote_delete_menu_item(todo) return link_to( image_tag("delete_off.png", :mouseover => "delete_on.png", :alt => t('todos.delete'), :align => "absmiddle")+" "+t('todos.delete'), - {:controller => 'todos', :action => 'destroy', :id => todo.id}, + {:controller => 'todos', :action => 'destroy', :id => todo.id}, :class => "icon_delete_item", :id => "delete_#{dom_id(todo)}", :x_confirm_message => t('todos.confirm_delete', :description => todo.description), @@ -88,12 +88,12 @@ module TodosHelper {:controller => "recurring_todos", :action => "index"}, :class => "recurring_icon", :title => recurrence_pattern_as_text(todo.recurring_todo)) end - + def remote_toggle_checkbox(todo=@todo) check_box_tag("mark_complete_#{todo.id}", toggle_check_todo_path(todo), todo.completed?, :class => 'item-checkbox', :title => todo.pending? ? t('todos.blocked_by', :predecessors => todo.uncompleted_predecessors.map(&:description).join(', ')) : "", :readonly => todo.pending?) end - + def date_span(todo=@todo) if todo.completed? content_tag(:span, {:class => :grey}) { format_date( todo.completed_at ) } @@ -106,7 +106,7 @@ module TodosHelper due_date( todo.due ) end end - + def successors_span(todo=@todo) unless todo.pending_successors.empty? pending_count = todo.pending_successors.length @@ -114,7 +114,7 @@ module TodosHelper image_tag( 'successor_off.png', :width=>'10', :height=>'16', :border=>'0', :title => title ) end end - + def grip_span(todo=@todo) unless todo.completed? image_tag('grip.png', :width => '7', :height => '16', :border => '0', @@ -122,17 +122,17 @@ module TodosHelper :class => 'grip') end end - + def tag_list_text(todo=@todo) todo.tags.collect{|t| t.name}.join(', ') end - + def tag_list(todo=@todo) tags_except_starred = todo.tags.reject{|t| t.name == Todo::STARRED_TAG_NAME} tag_list = tags_except_starred.collect{|t| "" + link_to(t.name, :controller => "todos", :action => "tag", :id => t.name) + ""}.join('') "#{tag_list}" end - + def tag_list_mobile(todo=@todo) tags_except_starred = todo.tags.reject{|t| t.name == Todo::STARRED_TAG_NAME} # removed the link. TODO: add link to mobile view of tagged actions @@ -142,13 +142,13 @@ module TodosHelper ""}.join('') if tag_list.empty? then "" else "#{tag_list}" end end - + def deferred_due_date(todo=@todo) if todo.deferred? && todo.due t('todos.action_due_on', :date => format_date(todo.due)) end end - + def project_and_context_links(todo, parent_container_type, opts = {}) str = '' if todo.completed? @@ -167,7 +167,7 @@ module TodosHelper end return str end - + # Uses the 'staleness_starts' value from settings.yml (in days) to colour the # background of the action appropriately according to the age of the creation # date: @@ -198,7 +198,7 @@ module TodosHelper end days = days_from_today(d) - + case days # overdue or due very soon! sound the alarm! when -1000..-1 @@ -219,7 +219,7 @@ module TodosHelper "#{t('todos.show_in_days', :days => days.to_s)} " end end - + def should_show_new_item source_view do |page| page.todo { return !@todo.hidden? } @@ -251,7 +251,7 @@ module TodosHelper def should_add_new_context return @new_context_created && !source_view_is(:project) end - + def parent_container_type return 'tickler' if source_view_is :deferred return 'project' if source_view_is :project @@ -259,18 +259,18 @@ module TodosHelper return 'tag' if source_view_is :tag return 'context' end - + def todo_container_is_empty default_container_empty = ( @down_count == 0 ) deferred_container_empty = ( @todo.deferred? && @remaining_deferred_count == 0) return default_container_empty || deferred_container_empty end - + def default_contexts_for_autocomplete projects = current_user.uncompleted.projects.find(:all, :include => [:context], :conditions => ['default_context_id is not null']) Hash[*projects.map{ |p| [escape_javascript(p.name), escape_javascript(p.default_context.name)] }.flatten].to_json end - + def default_tags_for_autocomplete projects = current_user.projects.uncompleted.find(:all, :conditions => ["default_tags != ''"]) Hash[*projects.map{ |p| [escape_javascript(p.name), p.default_tags] }.flatten].to_json @@ -283,7 +283,7 @@ module TodosHelper end joined_notes || "" end - + def formatted_pagination(total) s = will_paginate(@todos) (s.gsub(/(<\/[^<]+>)/, '\1 ')).chomp(' ') @@ -305,7 +305,7 @@ module TodosHelper def update_needs_to_remove_todo_from_container source_view do |page| - page.context { return @context_changed || @todo.deferred? || @todo.pending? } + page.context { return @context_changed || @todo.deferred? || @todo.pending? || @todo_should_be_hidden } page.project { return @todo_deferred_state_changed || @todo_pending_state_changed || @project_changed} page.deferred { return @context_changed || !(@todo.deferred? || @todo.pending?) } page.calendar { return @due_date_changed || !@todo.due } @@ -411,23 +411,23 @@ module TodosHelper html += "}}) " * animation.size return html + ";" end - + def reset_tab_index - $tracks_tab_index = 0 + $tracks_tab_index = 0 end - + def next_tab_index # make sure it exists if reset was not called. Set to 20 to avoid clashes with existing form in sidebar - $tracks_tab_index ||= 20 - + $tracks_tab_index ||= 20 + $tracks_tab_index = $tracks_tab_index + 1 return $tracks_tab_index end - + private - + def image_tag_for_star(todo) image_tag("blank.png", :title =>t('todos.star_action'), :class => "todo_star"+(todo.starred? ? " starred":""), :id => "star_img_"+todo.id.to_s) end - + end diff --git a/app/views/todos/destroy.js.erb b/app/views/todos/destroy.js.erb index 86808c58..8d9b1d43 100644 --- a/app/views/todos/destroy.js.erb +++ b/app/views/todos/destroy.js.erb @@ -4,12 +4,13 @@ remove_todo_from_page(); show_new_todo_if_todo_was_recurring(); activate_pending_todos(); + update_predecessors(); show_empty_messages(); <%- else -%> TracksPages.page_notify('error', "<%= t('todos.error_deleting_item', :description => @todo.description) %>", 8); <%- end -%> -<% if @saved +<% if @saved # do not send the js in case of an error -%> @@ -44,12 +45,12 @@ function remove_todo_from_page() { <%= show_empty_message_in_source_container %> $('#<%=dom_id(@todo)%>').slideUp(400, function() { $('#<%=dom_id(@todo)%>').remove(); - <% if source_view_is :calendar - # in calendar view it is possible to have a todo twice on the page + <% if source_view_is :calendar + # in calendar view it is possible to have a todo twice on the page -%> $('#<%=dom_id(@todo)%>').remove(); <% end %> - }); + }); <% end -%> } @@ -69,7 +70,7 @@ function show_new_todo_if_todo_was_recurring() { } function activate_pending_todos() { - <% # Activate pending todos that are successors of the completed + <% # Activate pending todos that are successors of the deleted if @saved && @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| @@ -89,10 +90,22 @@ function activate_pending_todos() { <% end -%> } +function update_predecessors() { +<% + if @todo_was_destroyed_from_pending_state + @uncompleted_predecessors.each do |p| -%> + if ($('#<%=item_container_id(p)%>')) { + $('#<%=dom_id(p)%>').html('<%=escape_javascript(render(:partial => p, :locals => { :parent_container_type => parent_container_type }))%>'); + } +<% end + end +%> +} + function html_for_new_recurring_todo() { return "<%= @saved && @new_recurring_todo ? escape_javascript(render(:partial => @new_recurring_todo, :locals => { :parent_container_type => parent_container_type })) : "" %>"; } -<% end +<% end # if @saved -%> diff --git a/features/context_edit.feature b/features/context_edit.feature index 8cca170d..25cb5c87 100644 --- a/features/context_edit.feature +++ b/features/context_edit.feature @@ -8,6 +8,9 @@ Feature: Edit a context | login | password | is_admin | | testuser | secret | false | And I have logged in as "testuser" with password "secret" + And I have a context called "@pc" + And I have a project called "test project" + And I have 2 todos in project "test project" in context "@pc" with tags "starred" @selenium Scenario: In place edit of context name @@ -19,17 +22,52 @@ Feature: Edit a context Then he should see that a context named "Errands" is not present And he should see that a context named "OutAndAbout" is present + @selenium Scenario: Editing the context of a todo will remove the todo - Given this is a pending scenario + When I go to the the context page for "@pc" + Then the badge should show 2 + When I edit the context of "todo 1" to "@laptop" + Then I should not see "todo 1" + And the badge should show 1 + @selenium Scenario: Editing the description of a a todo will update that todo - Given this is a pending scenario + When I go to the the context page for "@pc" + And I edit the description of "todo 1" to "changed" + Then I should not see "todo 1" + And I should see "changed" + @selenium Scenario: Editing the context of the last todo will remove the todo and show empty message - Given this is a pending scenario + When I go to the the context page for "@pc" + And I edit the context of "todo 1" to "@laptop" + Then I should not see "todo 1" + And the badge should show 1 + When I edit the context of "todo 2" to "@laptop" + Then I should not see "todo 2" + And the badge should show 0 + And I should see "Currently there are no incomplete actions in this context" + @selenium Scenario: Adding a todo to a hidden project will not show the todo - Given this is a pending scenario + Given I have a hidden project called "hidden project" + When I go to the the context page for "@pc" + And I edit the project of "todo 1" to "hidden project" + Then I should not see "todo 1" + When I submit a new action with description "todo X" to project "hidden project" in the context "@pc" + Then I should not see "todo X" + When I go to the "hidden project" project + Then I should see "todo 1" + And I should see "todo X" + And the badge should show 2 + @selenium Scenario: Adding a todo to a hidden context will show that todo - Given this is a pending scenario + Given I have a hidden context called "@personal" + When I go to the the context page for "@pc" + And I edit the context of "todo 1" to "@personal" + Then I should not see "todo 1" + When I go to the context page for "@personal" + Then I should see "todo 1" + When I submit a new action with description "todo X" to project "test project" in the context "@personal" + Then I should see "todo X" diff --git a/features/dependencies.feature b/features/dependencies.feature index b7dec50a..1f75bf47 100644 --- a/features/dependencies.feature +++ b/features/dependencies.feature @@ -92,8 +92,24 @@ Feature: dependencies And I should not see "test 2" in the deferred container And I should see the empty message in the deferred container + @selenium Scenario: Deleting a successor will update predecessor - Given this is a pending scenario + Given I have a context called "@pc" + And I have a project "dependencies" that has the following todos + | description | context | + | test 1 | @pc | + | test 2 | @pc | + | test 3 | @pc | + And "test 2" depends on "test 1" + And "test 3" depends on "test 1" + When I go to the "dependencies" project + And I expand the dependencies of "test 1" + Then I should see "test 2" within the dependencies of "test 1" + And I should see "test 3" within the dependencies of "test 1" + When I delete the action "test 2" + And I expand the dependencies of "test 1" + Then I should see "test 3" within the dependencies of "test 1" + And I should not see "test 2" @selenium Scenario: Dragging an action to a completed action will not add it as a dependency diff --git a/features/edit_a_todo.feature b/features/edit_a_todo.feature index fbe3c73e..bcaedbc1 100644 --- a/features/edit_a_todo.feature +++ b/features/edit_a_todo.feature @@ -153,9 +153,38 @@ Feature: Edit a next action from every page | tag page for "starred" | | calendar page | - Scenario: I can edit a todo to move it to another context - # for home and tickler and tag - Given this is a pending scenario + @selenium + Scenario Outline: I can edit a todo to move it to another context + Given I have a context called "@pc" + And I have a context called "@laptop" + And I have a project "my project" that has the following todos + | context | description | tags | + | @pc | first action | bla | + | @laptop | second action | bla | + When I go to the + Then I should see "first action" in the context container for "@pc" + When I edit the context of "first action" to "@laptop" + Then I should not see "first action" in the context container for "@pc" + Then I should see "first action" in the context container for "@laptop" + + Scenarios: + | page | + | home page | + | tag page for "bla" | + + @selenium + Scenario: I can edit a todo to move it to another context in tickler page + Given I have a context called "@pc" + And I have a context called "@laptop" + And I have a project "my project" that has the following deferred todos + | context | description | + | @pc | first action | + | @laptop | second action | + When I go to the tickler page + Then I should see "first action" in the context container for "@pc" + When I edit the context of "first action" to "@laptop" + Then I should not see "first action" in the context container for "@pc" + Then I should see "first action" in the context container for "@laptop" Scenario: I can edit a todo to move it to another project Given this is a pending scenario diff --git a/features/project_edit.feature b/features/project_edit.feature index cb6f38f8..c3741c59 100644 --- a/features/project_edit.feature +++ b/features/project_edit.feature @@ -103,6 +103,6 @@ Feature: Edit a project Given I have a project "foo" with 2 todos And I have a project called "bar" When I go to the "foo" project - And I change the project_name field of "Todo 1" to "bar" - Then I should not see "Todo 1" - And I should see "Todo 2" + And I change the project_name field of "todo 1" to "bar" + Then I should not see "todo 1" + And I should see "todo 2" diff --git a/features/shared_add_new_todo.feature b/features/shared_add_new_todo.feature index 523446eb..11f1cc65 100644 --- a/features/shared_add_new_todo.feature +++ b/features/shared_add_new_todo.feature @@ -200,15 +200,21 @@ Feature: Add new next action from every page @selenium Scenario: Adding a todo to an empty container hides the empty message # TODO: make outline - And I have a context called "visible context" + Given 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'" + @selenium Scenario: Adding a dependency to a todo updated the successor - Given this is a pending scenario + When I go to the "test project" project + Then I should see "todo 1" + When I submit a new action with description "a new todo" with a dependency on "todo 1" + Then I should not see "a new todo" in the project container of "test project" + When I expand the dependencies of "todo 1" + Then I should see "a new todo" within the dependencies of "todo 1" @selenium Scenario: I can add multiple todos in a new project and a new context diff --git a/features/step_definitions/container_steps.rb b/features/step_definitions/container_steps.rb index 76216a7d..e63fafb5 100644 --- a/features/step_definitions/container_steps.rb +++ b/features/step_definitions/container_steps.rb @@ -51,7 +51,7 @@ Then /^I should not see "([^"]*)" in the context container for "([^"]*)"$/ do |t todo.should_not be_nil xpath = "xpath=//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']" - + if selenium.is_element_present(xpath) # give jquery some time to finish wait_for :timeout_in_seconds => 5 do @@ -82,6 +82,23 @@ Then /^I should see "([^"]*)" in the action container$/ do |todo_description| end end +Then /^I should not see "([^"]*)" in the project container of "([^"]*)"$/ do |todo_description, project_name| + todo = @current_user.todos.find_by_description(todo_description) + todo.should_not be_nil + + project = @current_user.projects.find_by_name(project_name) + project.should_not be_nil + + xpath = "//div[@id='p#{todo.project.id}items']//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 + + 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 @@ -130,7 +147,7 @@ end Then /^I should see "([^"]*)" in the active recurring todos container$/ do |repeat_pattern| repeat = @current_user.recurring_todos.find_by_description(repeat_pattern) - + unless repeat.nil? xpath = "//div[@id='active_recurring_todos_container']//div[@id='recurring_todo_#{repeat.id}']" selenium.wait_for_element("xpath=#{xpath}", :timeout_in_seconds => 5) diff --git a/features/step_definitions/dependencies_steps.rb b/features/step_definitions/dependencies_steps.rb index 5de5cde4..3a30cd91 100644 --- a/features/step_definitions/dependencies_steps.rb +++ b/features/step_definitions/dependencies_steps.rb @@ -65,7 +65,7 @@ When /^I edit the dependency of "([^"]*)" to remove "([^"]*)" as predecessor$/ d wait_for :timeout=>5 do !selenium.is_element_present(delete_dep_button) end - + submit_edit_todo_form(todo) # note that animations will be running after the ajax is completed end @@ -109,6 +109,7 @@ Then /^I should not see "([^"]*)" within the dependencies of "([^"]*)"$/ do |suc successor.should_not be_nil # let selenium look for the presence of the successor xpath = "xpath=//div[@id='line_todo_#{todo.id}']//div[@id='successor_line_todo_#{successor.id}']//span" + wait_for :timeout => 5 do !selenium.is_element_present(xpath) end diff --git a/features/step_definitions/project_steps.rb b/features/step_definitions/project_steps.rb index 233dc50a..8ca46b2f 100644 --- a/features/step_definitions/project_steps.rb +++ b/features/step_definitions/project_steps.rb @@ -1,11 +1,11 @@ Given /^I have a project "([^\"]*)" with (.*) todos$/ do |project_name, num_todos| - context = @current_user.contexts.find_or_create_by_name("Context A") - project = @current_user.projects.create!(:name => project_name) + @context = @current_user.contexts.find_or_create_by_name("Context A") + @project = @current_user.projects.create!(:name => project_name) 1.upto num_todos.to_i do |i| @current_user.todos.create!( - :project_id => project.id, - :context_id => context.id, - :description => "Todo #{i}") + :project_id => @project.id, + :context_id => @context.id, + :description => "todo #{i}") end end @@ -71,7 +71,7 @@ When /^I edit the project name to "([^\"]*)"$/ do |new_title| wait_for do selenium.is_element_present("submit_project_#{@project.id}") end - + fill_in "project[name]", :with => new_title selenium.click "submit_project_#{@project.id}", @@ -180,7 +180,7 @@ Then /^I should see the bold text "([^\"]*)" in the project description$/ do |bo response.should have_xpath(xpath) bold_text = response.selenium.get_text("xpath=#{xpath}") - + bold_text.should =~ /#{bold}/ end diff --git a/features/step_definitions/todo_create_steps.rb b/features/step_definitions/todo_create_steps.rb index 01fd572d..ea51fa65 100644 --- a/features/step_definitions/todo_create_steps.rb +++ b/features/step_definitions/todo_create_steps.rb @@ -3,6 +3,30 @@ When /^I submit a new action with description "([^"]*)"$/ do |description| submit_next_action_form end +When /^I submit a new action with description "([^"]*)" with a dependency on "([^"]*)"$/ do |todo_description, predecessor_description| + predecessor = @current_user.todos.find_by_description(predecessor_description) + predecessor.should_not be_nil + + fill_in "todo[description]", :with => todo_description + + input = "xpath=//form[@id='todo-form-new-action']//input[@id='predecessor_input']" + selenium.focus(input) + selenium.type_keys input, predecessor_description + + # wait for auto complete + autocomplete = "xpath=//a[@id='ui-active-menuitem']" + selenium.wait_for_element(autocomplete, :timeout_in_seconds => 5) + + # click first line + first_elem = "xpath=//ul/li[1]/a[@id='ui-active-menuitem']" + selenium.click(first_elem) + + new_dependency_line = "xpath=//li[@id='pred_#{predecessor.id}']" + selenium.wait_for_element(new_dependency_line, :timeout_in_seconds => 5) + + submit_next_action_form +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 diff --git a/features/step_definitions/todo_edit_steps.rb b/features/step_definitions/todo_edit_steps.rb index 2be789f1..2865cf52 100644 --- a/features/step_definitions/todo_edit_steps.rb +++ b/features/step_definitions/todo_edit_steps.rb @@ -7,8 +7,12 @@ When /I change the (.*) field of "([^\"]*)" to "([^\"]*)"$/ do |field_name, todo submit_edit_todo_form(todo) end -When /^I edit the context of "([^"]*)" to "([^"]*)"$/ do |context_old_name, context_new_name| - When "I change the context_name field of \"#{context_old_name}\" to \"#{context_new_name}\"" +When /^I edit the context of "([^"]*)" to "([^"]*)"$/ do |todo_name, context_new_name| + When "I change the context_name field of \"#{todo_name}\" to \"#{context_new_name}\"" +end + +When /^I edit the project of "([^"]*)" to "([^"]*)"$/ do |todo_name, project_new_name| + When "I change the project_name field of \"#{todo_name}\" to \"#{project_new_name}\"" end When /^I edit the description of "([^"]*)" to "([^"]*)"$/ do |action_description, new_description| @@ -46,9 +50,9 @@ end When /^I remove the show from date from "([^"]*)"$/ do |action_description| todo = @current_user.todos.find_by_description(action_description) todo.should_not be_nil - + open_edit_form_for(todo) selenium.click("//div[@id='edit_todo_#{todo.id}']//a[@id='show_from_x_todo_#{todo.id}']/img", :wait_for => :ajax, :javascript_framework => :jquery) - + submit_edit_todo_form(todo) end diff --git a/features/step_definitions/todo_steps.rb b/features/step_definitions/todo_steps.rb index d91f9eb1..488a92f3 100644 --- a/features/step_definitions/todo_steps.rb +++ b/features/step_definitions/todo_steps.rb @@ -4,7 +4,7 @@ end Given /^I have a todo "([^"]*)" in the context "([^"]*)"$/ do |description, context_name| context = @current_user.contexts.find_or_create(:name => context_name) - @current_user.todos.create!(:context_id => context.id, :description => description) + @todo = @current_user.todos.create!(:context_id => context.id, :description => description) end Given /^I have a todo "([^"]*)" in the context "([^"]*)" which is due tomorrow$/ do |description, context_name| @@ -14,6 +14,22 @@ Given /^I have a todo "([^"]*)" in the context "([^"]*)" which is due tomorrow$/ @todo.save! end +Given /^I have (\d+) todos in project "([^"]*)" in context "([^"]*)" with tags "([^"]*)"$/ do |number_of_todos, project_name, context_name, tag_names| + @context = @current_user.contexts.find_by_name(context_name) + @context.should_not be_nil + + @project = @current_user.projects.find_by_name(project_name) + @project.should_not be_nil + + @todos = [] + number_of_todos.to_i.downto 1 do |i| + todo = @current_user.todos.create!(:context_id => @context.id, :description => "todo #{i}", :project_id => @project.id) + todo.tag_with(tag_names) + todo.save! + @todos << todo + end +end + Given /^I have a todo "([^"]*)"$/ do |description| Given "I have a todo \"#{description}\" in the context \"Context A\"" end @@ -133,6 +149,26 @@ Given /^I have a project "([^"]*)" that has the following todos$/ do |project_na end end +Given /^I have a project "([^"]*)" that has the following deferred todos$/ do |project_name, todos| + Given "I have a project called \"#{project_name}\"" + @project.should_not be_nil + todos.hashes.each do |todo| + context = @current_user.contexts.find_by_name(todo[:context]) + context.should_not be_nil + new_todo = @current_user.todos.create!( + :description => todo[:description], + :context_id => context.id, + :project_id=>@project.id, + :show_from=>Time.zone.now+1.week) + unless todo[:tags].nil? + new_todo.tag_with(todo[:tags]) + end + unless todo[:completed].nil? + new_todo.complete! if todo[:completed] == 'yes' + end + end +end + When /^I mark "([^"]*)" as complete$/ do |action_description| todo = @current_user.todos.find_by_description(action_description) todo.should_not be_nil diff --git a/features/view_done.feature b/features/view_done.feature index 5dd1c7f6..4f9b1fee 100644 --- a/features/view_done.feature +++ b/features/view_done.feature @@ -133,7 +133,7 @@ Feature: Show done When I go to the recurring todos page Then I should see "test pattern" in the active recurring todos container - @selenium @wip + @selenium Scenario Outline: I can toggle a todo active from the done pages When I go to the Then I should see "todo 1" @@ -173,7 +173,14 @@ Feature: Show done @selenium Scenario: I can edit a project to active from the project done page - Given this scenario is pending + Given I have a completed project called "completed project" + 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" + When I go to the projects page + Then I should see "completed project" + Scenario Outline: All pages are internationalized Given I set the locale to "" @@ -206,3 +213,20 @@ Feature: Show done | all done actions page for context "@pc" | de | | all done actions page for project "test project"| de | | all done actions page for tag "starred" | de | + | done actions page | es | + | all done actions page | es | + | done actions page for context "@pc" | es | + | done actions page for project "test project" | es | + | done actions page for tag "starred" | es | + | all done actions page for context "@pc" | es | + | all done actions page for project "test project"| es | + | all done actions page for tag "starred" | es | +# fr locale needs changes from preference branch +# | done actions page | fr | +# | all done actions page | fr | +# | done actions page for context "@pc" | fr | +# | done actions page for project "test project" | fr | +# | done actions page for tag "starred" | fr | +# | all done actions page for context "@pc" | fr | +# | all done actions page for project "test project"| fr | +# | all done actions page for tag "starred" | fr |