mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-18 00:00:12 +01:00
Show deferred actions on the project listing and sidebar
If a project does not have any active actions, then it will now display that it has x number of deferred actions. Fixes #1084
This commit is contained in:
parent
4d5a40c376
commit
b387b27f4a
3 changed files with 70 additions and 6 deletions
|
|
@ -91,8 +91,15 @@ class ApplicationController < ActionController::Base
|
||||||
#
|
#
|
||||||
def count_undone_todos_phrase(todos_parent, string="actions")
|
def count_undone_todos_phrase(todos_parent, string="actions")
|
||||||
count = count_undone_todos(todos_parent)
|
count = count_undone_todos(todos_parent)
|
||||||
word = count == 1 ? string.singularize : string.pluralize
|
deferred_count = count_deferred_todos(todos_parent)
|
||||||
return count.to_s + " " + word
|
if count == 0 && deferred_count > 0
|
||||||
|
word = deferred_count == 1 ? string.singularize : string.pluralize
|
||||||
|
word = "deferred " + word
|
||||||
|
deferred_count.to_s + " " + word
|
||||||
|
else
|
||||||
|
word = count == 1 ? string.singularize : string.pluralize
|
||||||
|
count.to_s + " " + word
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def count_undone_todos(todos_parent)
|
def count_undone_todos(todos_parent)
|
||||||
|
|
@ -106,6 +113,14 @@ class ApplicationController < ActionController::Base
|
||||||
count || 0
|
count || 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def count_deferred_todos(todos_parent)
|
||||||
|
if todos_parent.nil?
|
||||||
|
count = 0
|
||||||
|
else
|
||||||
|
count = todos_parent.todos.deferred.count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Convert a date object to the format specified in the user's preferences in
|
# Convert a date object to the format specified in the user's preferences in
|
||||||
# config/settings.yml
|
# config/settings.yml
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -116,25 +116,25 @@ Feature: Manage the list of projects
|
||||||
And the badge should show 4
|
And the badge should show 4
|
||||||
And the project list badge for "active" projects should show 4
|
And the project list badge for "active" projects should show 4
|
||||||
|
|
||||||
@selenium @wip
|
@selenium
|
||||||
Scenario: Listing projects with only active actions
|
Scenario: Listing projects with only active actions
|
||||||
Given I have a project "do it now" with 2 active todos
|
Given I have a project "do it now" with 2 active todos
|
||||||
When I go to the projects page
|
When I go to the projects page
|
||||||
Then the project "do it now" should have 2 actions listed
|
Then the project "do it now" should have 2 actions listed
|
||||||
|
|
||||||
@selenium @wip
|
@selenium
|
||||||
Scenario: Listing projects with both active and deferred actions
|
Scenario: Listing projects with both active and deferred actions
|
||||||
Given I have a project "now and later" with 2 active actions and 2 deferred actions
|
Given I have a project "now and later" with 2 active actions and 2 deferred actions
|
||||||
When I go to the projects page
|
When I go to the projects page
|
||||||
Then the project "now and later" should have 2 actions listed
|
Then the project "now and later" should have 2 actions listed
|
||||||
|
|
||||||
@selenium @wip
|
@selenium
|
||||||
Scenario: Listing projects with only deferred actions
|
Scenario: Listing projects with only deferred actions
|
||||||
Given I have a project "only later" with 3 deferred actions
|
Given I have a project "only later" with 3 deferred actions
|
||||||
When I go to the projects page
|
When I go to the projects page
|
||||||
Then the project "only later" should have 3 deferred actions listed
|
Then the project "only later" should have 3 deferred actions listed
|
||||||
|
|
||||||
@selenium @wip
|
@selenium
|
||||||
Scenario: Listing projects with no actions
|
Scenario: Listing projects with no actions
|
||||||
Given I have a project "all done" with 0 active actions and 0 deferred actions
|
Given I have a project "all done" with 0 active actions and 0 deferred actions
|
||||||
When I go to the projects page
|
When I go to the projects page
|
||||||
|
|
|
||||||
|
|
@ -90,3 +90,52 @@ end
|
||||||
Then /^the new project form should not be visible$/ do
|
Then /^the new project form should not be visible$/ do
|
||||||
selenium.is_visible("project_new").should == false
|
selenium.is_visible("project_new").should == false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Given /^I have a project "([^"]*)" with (\d+) active todos$/ do |name, count|
|
||||||
|
@context = @current_user.contexts.find_or_create_by_name("Context A")
|
||||||
|
@project = @current_user.projects.find_or_create_by_name(name)
|
||||||
|
|
||||||
|
@todos=[]
|
||||||
|
1.upto count.to_i do |i|
|
||||||
|
todo = @current_user.todos.create!(
|
||||||
|
:project_id => @project.id,
|
||||||
|
:context_id => @context.id,
|
||||||
|
:description => "todo #{i}")
|
||||||
|
@todos << todo
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^the project "([^"]*)" should have (\d+) actions listed$/ do |name, count|
|
||||||
|
project = @current_user.projects.find_by_name(name)
|
||||||
|
project.should_not be_nil
|
||||||
|
xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']//span[@class='needsreview']"
|
||||||
|
selenium.get_text("xpath=#{xpath}").should == "#{project.name} (#{count} actions)"
|
||||||
|
end
|
||||||
|
|
||||||
|
Given /^I have a project "([^"]*)" with (\d+) active actions and (\d+) deferred actions$/ do |name, active_count, deferred_count|
|
||||||
|
Given "I have a project \"#{name}\" with #{active_count} active todos"
|
||||||
|
Given "I have a project \"#{name}\" with #{deferred_count} deferred actions"
|
||||||
|
end
|
||||||
|
|
||||||
|
Given /^I have a project "([^"]*)" with (\d+) deferred actions$/ do |name, deferred|
|
||||||
|
@context = @current_user.contexts.find_or_create_by_name("Context A")
|
||||||
|
@project = @current_user.projects.find_or_create_by_name(name)
|
||||||
|
|
||||||
|
1.upto deferred.to_i do |i|
|
||||||
|
todo = @current_user.todos.create!(
|
||||||
|
:project_id => @project.id,
|
||||||
|
:context_id => @context.id,
|
||||||
|
:description => "deferred todo #{i}")
|
||||||
|
todo.show_from = Time.zone.now + 1.week
|
||||||
|
todo.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^the project "([^"]*)" should have (\d+) deferred actions listed$/ do |name, deferred|
|
||||||
|
project = @current_user.projects.find_by_name(name)
|
||||||
|
project.should_not be_nil
|
||||||
|
xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']//span[@class='needsreview']"
|
||||||
|
selenium.get_text("xpath=#{xpath}").should == "#{project.name} (#{deferred} deferred actions)"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue