Merge pull request #62 from Popsch/review_tests_rebase

cucumber tests for the review mode
This commit is contained in:
Matt Rogers 2012-02-10 08:27:54 -08:00
commit 67b8a11600
4 changed files with 63 additions and 1 deletions

36
features/review.feature Normal file
View file

@ -0,0 +1,36 @@
Feature: Reviewing projects
In order to keep the todos and projects up to date
As a Tracks user
I want to review my projects
Background:
Given the following user record
| login | password | is_admin |
| testuser | secret | false |
And I have logged in as "testuser" with password "secret"
Scenario: I see stalled projects
Given I have no projects
Given I have a project "stalled_project" with 0 todos
When I go to the review page
Then I see the project "stalled_project" in the "stalled" list
Scenario: I see blocked projects
Given I have no projects
Given I have a project "blocked_project" with 1 deferred todos
When I go to the review page
Then I see the project "blocked_project" in the "blocked" list
Scenario: I see dated projects
Given I have no projects
Given I have an outdated project "dated_project" with 1 todos
When I go to the review page
Then I see the project "dated_project" in the "review" list
Scenario: The review list of projects contains all projects
Given I have no projects
Given I have a project "stalled_project" with 0 todos
Given I have a project "blocked_project" with 1 deferred todos
Given I have an outdated project "dated_project" with 1 todos
When I go to the review page
And the badge should show 5 ## note that stalled and blocked projects are also up-to-date listed

View file

@ -1,3 +1,10 @@
Given /^I have an outdated project "([^"]*)" with (\d+) todos$/ do |project_name, num_todos|
Given "I have a project \"#{project_name}\" with #{num_todos} todos"
@project = @current_user.projects.find_by_name(project_name)
@project.last_reviewed = @current_user.time - @current_user.prefs.review_period.days-1
@project.save
end
Given /^I have a project "([^\"]*)" with ([0-9]+) 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)

View file

@ -0,0 +1,9 @@
Then /^I see the project "([^"]*)" in the "([^"]*)" list$/ do |name, state|
project = @current_user.projects.find_by_name(name)
project.should_not be_nil
xpath = "//div[@id='list-#{state}-projects']//div[@id='project_#{project.id}']"
response.should have_xpath(xpath)
end

View file

@ -68,7 +68,17 @@ class ProjectTest < ActiveSupport::TestCase
assert_equal :active, @timemachine.aasm_current_state
assert @timemachine.active?
end
def test_review_project
assert_nil @timemachine.last_reviewed
assert @timemachine.needs_review?(nil)
end
def test_review_completedprojects
@timemachine.complete!
assert !@timemachine.needs_review?(nil)
end
def test_complete_project
assert_nil @timemachine.completed_at
@timemachine.complete!