add cucumber scenarios for the new done pages

This commit is contained in:
Reinier Balt 2011-06-17 20:17:01 +02:00
parent e531907521
commit 5496b84642
8 changed files with 123 additions and 11 deletions

View file

@ -19,6 +19,8 @@ class ContextsController < ApplicationController
@all_contexts = @active_contexts + @hidden_contexts
@count = @all_contexts.size
init_not_done_counts(['context'])
respond_to do |format|
format.html &render_contexts_html
format.m &render_contexts_mobile

View file

@ -14,8 +14,10 @@ class ProjectsController < ApplicationController
projects_and_actions
else
@contexts = current_user.contexts.all
init_not_done_counts(['project'])
init_project_hidden_todo_counts(['project'])
if params[:only_active_with_no_next_actions]
@projects = current_user.projects.active.select { |p| p.todos.count == 0 }
@projects = current_user.projects.active.select { |p| count_undone_todos(p) == 0 }
else
@projects = current_user.projects.all
end
@ -207,12 +209,14 @@ class ProjectsController < ApplicationController
@state = params['state']
@projects = current_user.projects.alphabetize(:state => @state) if @state
@contexts = current_user.contexts
init_not_done_counts(['project'])
end
def actionize
@state = params['state']
@projects = current_user.projects.actionize(:state => @state) if @state
@contexts = current_user.contexts
init_not_done_counts(['project'])
end
def done_todos

View file

@ -646,10 +646,12 @@ class StatsController < ApplicationController
def done
@source_view = 'done'
@done_recently = current_user.todos.completed.all(:limit => 10, :order => 'completed_at DESC', :include => [:project, :context, :tags, :taggings])
init_not_done_counts
@done_recently = current_user.todos.completed.all(:limit => 10, :order => 'completed_at DESC', :include => Todo::DEFAULT_INCLUDES)
@last_completed_projects = current_user.projects.completed.all(:limit => 10, :order => 'completed_at DESC', :include => [:todos, :notes])
@last_completed_contexts = []
@last_completed_recurring_todos = current_user.recurring_todos.completed.all(:limit => 10, :order => 'completed_at DESC')
@last_completed_recurring_todos = current_user.recurring_todos.completed.all(:limit => 10, :order => 'completed_at DESC', :include => [:tags, :taggings])
#TODO: @last_completed_contexts = current_user.contexts.completed.all(:limit => 10, :order => 'completed_at DESC')
end

View file

@ -108,6 +108,7 @@ en:
months: months
week: week
weeks: weeks
recurring_todos: Repeating Actions
errors:
user_unauthorized: "401 Unauthorized: Only administrative users are allowed access to this function."
footer:

View file

@ -60,7 +60,6 @@ Then /^I should not see "([^"]*)" in the context container for "([^"]*)"$/ do |t
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

View file

@ -44,16 +44,35 @@ Given /^I have a deferred todo "([^"]*)" in the context "([^"]*)"$/ do |descript
todo.save!
end
Given /^I have ([0-9]+) completed todos$/ do |count|
context = @current_user.contexts.create!(:name => "context C")
Given /^I have ([0-9]+) completed todos in project "([^"]*)" in context "([^"]*)"$/ do |count, project_name, context_name|
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
count.to_i.downto 1 do |i|
todo = @current_user.todos.create!(:context_id => context.id, :description => "todo #{i}", :project_id => project.id)
todo.complete!
end
end
Given /^I have ([0-9]+) completed todos in context "([^"]*)"$/ do |count, context_name|
context = @current_user.contexts.find_by_name(context_name)
context.should_not be_nil
count.to_i.downto 1 do |i|
todo = @current_user.todos.create!(:context_id => context.id, :description => "todo #{i}")
todo.complete!
end
end
Given /^I have ([0-9]+) completed todos$/ do |count|
Given "I have #{count} completed todos in the context \"context D\""
end
Given /^I have ([0-9]+) completed todos with a note$/ do |count|
context = @current_user.contexts.create!(:name => "context D")
context = @current_user.contexts.find_or_create(:name => "context D")
count.to_i.downto 1 do |i|
todo = @current_user.todos.create!(:context_id => context.id, :description => "todo #{i}", :notes => "note #{i}")
todo.complete!
@ -275,3 +294,18 @@ Then /^the selected context should be "([^"]*)"$/ do |content|
# Works for mobile. TODO: make it work for both mobile and non-mobile
field_labeled("Context").element.search(".//option[@selected = 'selected']").inner_html.should =~ /#{content}/
end
Then /^I should see the page selector$/ do
page_selector_xpath = ".//a[@class='next_page']"
response.body.should have_xpath(page_selector_xpath)
end
Then /^the page should be "([^"]*)"$/ do |page_number|
page_number_found = -1
page_number_xpath = ".//span[@class='current']"
response.should have_xpath(page_number_xpath) do |node|
page_number_found = node.first.content.to_i
end
page_number_found.should == page_number.to_i
end

View file

@ -13,6 +13,18 @@ module NavigationHelpers
when /the home\s?page/
@source_view = "todos"
root_path(options)
when /the done page/
done_overview_path(options)
when /the done actions page for context "([^"]*)"/i
context = @current_user.contexts.find_by_name($1)
done_todos_context_path(context)
when /the done actions page for project "([^"]*)"/i
project = @current_user.projects.find_by_name($1)
done_todos_project_path(project)
when /the done actions page/
done_todos_path(options)
when /the all done actions page/
all_done_todos_path(options)
when /the statistics page/
@source_view = "stats"
stats_path(options)

View file

@ -7,9 +7,67 @@ Feature: Show done
Given the following user record
| login | password | is_admin |
| testuser | secret | false |
Scenario: Visit done page
Given I have logged in as "testuser" with password "secret"
And I have logged in as "testuser" with password "secret"
And I have 1 completed todos with a note
Scenario: Visit done overview page
When I go to the done page
Then I should see "Completed in the last 24 hours"
Then I should see "Last Completed Actions"
And I should see "Last Completed Projects"
And I should see "Last Completed Repeating Actions"
Scenario: Home page links to show all completed todos
When I go to the home page
Then I should see "Completed actions"
And I should see "Show all"
When I follow "Show all"
Then I should be on the done actions page
Scenario Outline: I can see all todos completed in the last timeperiod
Given I have a context called "@pc"
And I have a project called "test"
And I have 1 completed todos in project "test" in context "@pc"
When I go to the <page>
Then I should see "todo 1"
And I should see "Completed today"
And I should see "Completed in the rest of this week"
And I should see "Completed in the rest of this month"
Scenarios:
| page |
| done actions page |
| done actions page for context "@pc" |
| done actions page for project "test" |
Scenario: I can see all todos completed
When I go to the done actions page
And I should see "You can see all completed actions here"
When I follow "here"
Then I should be on the all done actions page
Scenario: I can browse all todos completed by page
Given I have 50 completed todos with a note
When I go to the all done actions page
Then I should see the page selector
When I follow "2"
Then I should be on the all done actions page
And the page should be "2"
Scenario: The context page for a context shows a link to all completed actions
Given I have a context called "@pc"
And I have 1 completed todos in context "@pc"
When I go to the context page for "@pc"
Then I should see "Completed actions"
And I should see "Show all"
When I follow "Show all"
Then I should be on the done actions page for context "@pc"
Scenario: The project page for a project shows a link to all completed actions
Given I have a context called "@pc"
And I have a project called "test"
And I have 1 completed todos in project "test" in context "@pc"
When I go to the "test" project
Then I should see "Completed actions"
And I should see "Show all"
When I follow "Show all"
Then I should be on the done actions page for project "test"