mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
start modifying done view and do some refactoring
This commit is contained in:
parent
de7b8e329d
commit
01057af684
19 changed files with 160 additions and 202 deletions
|
|
@ -212,14 +212,14 @@ class ContextsController < ApplicationController
|
|||
def render_contexts_rss_feed
|
||||
lambda do
|
||||
render_rss_feed_for current_user.contexts.all, :feed => feed_options,
|
||||
:item => { :description => lambda { |c| c.summary(count_undone_todos_phrase(c)) } }
|
||||
:item => { :description => lambda { |c| @template.summary(c, count_undone_todos_phrase(c)) } }
|
||||
end
|
||||
end
|
||||
|
||||
def render_contexts_atom_feed
|
||||
lambda do
|
||||
render_atom_feed_for current_user.contexts.all, :feed => feed_options,
|
||||
:item => { :description => lambda { |c| c.summary(count_undone_todos_phrase(c)) },
|
||||
:item => { :description => lambda { |c| @template.summary(c, count_undone_todos_phrase(c)) },
|
||||
:author => lambda { |c| nil } }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ class ProjectsController < ApplicationController
|
|||
@page_title = t('projects.page_title', :project => @project.name)
|
||||
|
||||
@not_done = @project.todos.active_or_hidden(:include => [:tags, :context, :predecessors])
|
||||
@deferred = @project.deferred_todos(:include => [:tags, :context, :predecessors])
|
||||
@pending = @project.pending_todos(:include => [:tags, :context, :predecessors])
|
||||
@deferred = @project.todos.deferred(:include => [:tags, :context, :predecessors])
|
||||
@pending = @project.todos.pending(:include => [:tags, :context, :predecessors])
|
||||
@done = @project.todos.find_in_state(:all, :completed,
|
||||
:order => "todos.completed_at DESC", :limit => current_user.prefs.show_number_completed, :include => [:context, :tags, :predecessors])
|
||||
|
||||
|
|
@ -274,14 +274,14 @@ class ProjectsController < ApplicationController
|
|||
lambda do
|
||||
render_rss_feed_for @projects, :feed => feed_options,
|
||||
:title => :name,
|
||||
:item => { :description => lambda { |p| summary(p) } }
|
||||
:item => { :description => lambda { |p| @template.summary(p) } }
|
||||
end
|
||||
end
|
||||
|
||||
def render_atom_feed
|
||||
lambda do
|
||||
render_atom_feed_for @projects, :feed => feed_options,
|
||||
:item => { :description => lambda { |p| summary(p) },
|
||||
:item => { :description => lambda { |p| @template.summary(p) },
|
||||
:title => :name,
|
||||
:author => lambda { |p| nil } }
|
||||
end
|
||||
|
|
@ -319,13 +319,4 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def summary(project)
|
||||
project_description = ''
|
||||
project_description += sanitize(markdown( project.description )) unless project.description.blank?
|
||||
project_description += "<p>#{count_undone_todos_phrase(p)}. "
|
||||
project_description += t('projects.project_state', :state => project.state)
|
||||
project_description += "</p>"
|
||||
project_description
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ class TodosController < ApplicationController
|
|||
append_before_filter :find_and_activate_ready, :only => [:index, :list_deferred]
|
||||
|
||||
# TODO: replace :except with :only
|
||||
append_before_filter :init, :except => [ :tag, :tags, :destroy, :completed,
|
||||
:completed_archive, :check_deferred, :toggle_check, :toggle_star,
|
||||
:edit, :update, :defer, :create, :calendar, :auto_complete_for_predecessor, :remove_predecessor, :add_predecessor]
|
||||
append_before_filter :init, :except => [ :tag, :tags, :destroy, :done,
|
||||
:check_deferred, :toggle_check, :toggle_star, :edit, :update, :defer, :create,
|
||||
:calendar, :auto_complete_for_predecessor, :remove_predecessor, :add_predecessor]
|
||||
|
||||
protect_from_forgery :except => :check_deferred
|
||||
|
||||
|
|
@ -349,7 +349,7 @@ class TodosController < ApplicationController
|
|||
determine_remaining_in_context_count(@original_item_context_id)
|
||||
|
||||
respond_to do |format|
|
||||
format.js {render :action => :update }
|
||||
format.js { render :action => :update }
|
||||
format.xml { render :xml => @todo.to_xml( :except => :user_id ) }
|
||||
end
|
||||
end
|
||||
|
|
@ -468,21 +468,16 @@ class TodosController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def completed
|
||||
def done
|
||||
@source_view = 'done'
|
||||
@page_title = t('todos.completed_tasks_title')
|
||||
@done = current_user.completed_todos
|
||||
@done_today = @done.completed_within Time.zone.now - 1.day
|
||||
@done_this_week = @done.completed_within Time.zone.now - 1.week
|
||||
@done_this_month = @done.completed_within Time.zone.now - 4.week
|
||||
completed_todos = current_user.todos.completed
|
||||
@done_today = completed_todos.completed_after(Time.zone.now.beginning_of_day)
|
||||
@done_this_week = completed_todos.completed_after(Time.zone.now.beginning_of_week)-@done_today
|
||||
@done_this_month = completed_todos.completed_after(Time.zone.now.beginning_of_month)-@done_this_week
|
||||
@done_previous_month = completed_todos.completed_after( (Time.zone.now.beginning_of_month - 1.day).beginning_of_month)-@done_this_month
|
||||
@count = @done_today.size + @done_this_week.size + @done_this_month.size
|
||||
end
|
||||
|
||||
def completed_archive
|
||||
@page_title = t('todos.archived_tasks_title')
|
||||
@done = current_user.completed_todos
|
||||
@count = @done.size
|
||||
@done_archive = @done.completed_more_than Time.zone.now - 28.days
|
||||
end
|
||||
|
||||
def list_deferred
|
||||
@source_view = 'deferred'
|
||||
|
|
@ -490,7 +485,7 @@ class TodosController < ApplicationController
|
|||
|
||||
@contexts_to_show = @contexts = current_user.contexts.find(:all)
|
||||
|
||||
@not_done_todos = current_user.deferred_todos(:include => [:tags, :taggings, :projects]) + current_user.pending_todos(:include => [:tags, :taggings, :projects])
|
||||
@not_done_todos = current_user.todos.deferred(:include => [:tags, :taggings, :projects]) + current_user.todos.pending(:include => [:tags, :taggings, :projects])
|
||||
@down_count = @count = @not_done_todos.size
|
||||
|
||||
respond_to do |format|
|
||||
|
|
|
|||
|
|
@ -1,25 +1,30 @@
|
|||
module ContextsHelper
|
||||
|
||||
def get_listing_sortable_options
|
||||
{
|
||||
:tag => 'div',
|
||||
:handle => 'handle',
|
||||
:complete => visual_effect(:highlight, 'list-contexts'),
|
||||
:url => order_contexts_path
|
||||
}
|
||||
end
|
||||
def get_listing_sortable_options
|
||||
{
|
||||
:tag => 'div',
|
||||
:handle => 'handle',
|
||||
:complete => visual_effect(:highlight, 'list-contexts'),
|
||||
:url => order_contexts_path
|
||||
}
|
||||
end
|
||||
|
||||
def link_to_delete_context(context, descriptor = sanitize(context.name))
|
||||
link_to(
|
||||
descriptor,
|
||||
context_path(context, :format => 'js'),
|
||||
{
|
||||
:id => "delete_context_#{context.id}",
|
||||
:class => "delete_context_button",
|
||||
:x_confirm_message => t('contexts.delete_context_confirmation', :name => context.name),
|
||||
:title => t('contexts.delete_context_title')
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
def summary(context, undone_todo_count)
|
||||
content_tag(:p, "#{undone_todo_count}. Context is #{context.hidden? ? 'Hidden' : 'Active'}.")
|
||||
end
|
||||
|
||||
def link_to_delete_context(context, descriptor = sanitize(context.name))
|
||||
link_to(
|
||||
descriptor,
|
||||
context_path(context, :format => 'js'),
|
||||
{
|
||||
:id => "delete_context_#{context.id}",
|
||||
:class => "delete_context_button",
|
||||
:x_confirm_message => t('contexts.delete_context_confirmation', :name => context.name),
|
||||
:title => t('contexts.delete_context_title')
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -57,5 +57,14 @@ module ProjectsHelper
|
|||
}
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
def summary(project)
|
||||
project_description = ''
|
||||
project_description += sanitize(markdown( project.description )) unless project.description.blank?
|
||||
project_description += content_tag(:p,
|
||||
"#{count_undone_todos_phrase(p)}. " + t('projects.project_state', :state => project.state)
|
||||
)
|
||||
project_description
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class Context < ActiveRecord::Base
|
|||
validates_does_not_contain :name, :string => ',', :message => "cannot contain the comma (',') character"
|
||||
|
||||
def self.feed_options(user)
|
||||
# TODO: move to view or helper
|
||||
{
|
||||
:title => 'Tracks Contexts',
|
||||
:description => "Lists all the contexts for #{user.display_name}"
|
||||
|
|
@ -36,14 +37,7 @@ class Context < ActiveRecord::Base
|
|||
def title
|
||||
name
|
||||
end
|
||||
|
||||
def summary(undone_todo_count)
|
||||
s = "<p>#{undone_todo_count}. "
|
||||
s += "Context is #{hidden? ? 'Hidden' : 'Active'}."
|
||||
s += "</p>"
|
||||
s
|
||||
end
|
||||
|
||||
|
||||
def new_record_before_save?
|
||||
@new_record_before_save
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,28 +1,5 @@
|
|||
class Project < ActiveRecord::Base
|
||||
has_many :todos, :dependent => :delete_all
|
||||
|
||||
# TODO: remove these scopes. Can be replaced by the named scopes on the todo relation
|
||||
has_many :not_done_todos,
|
||||
:include => [:context,:tags,:project],
|
||||
:class_name => 'Todo',
|
||||
:order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC",
|
||||
:conditions => ["todos.state = ?", 'active']
|
||||
has_many :done_todos,
|
||||
:include => [:context,:tags,:project],
|
||||
:class_name => 'Todo',
|
||||
:order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC",
|
||||
:conditions => ["todos.state = ?", 'completed']
|
||||
has_many :deferred_todos,
|
||||
:include => [:context,:tags,:project],
|
||||
:class_name => 'Todo',
|
||||
:conditions => ["todos.state = ? ", "deferred"],
|
||||
:order => "show_from"
|
||||
has_many :pending_todos,
|
||||
:include => [:context,:tags,:project],
|
||||
:class_name => 'Todo',
|
||||
:conditions => ["todos.state = ? ", "pending"],
|
||||
:order => "show_from"
|
||||
|
||||
has_many :notes, :dependent => :delete_all, :order => "created_at DESC"
|
||||
has_many :recurring_todos
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
class Todo < ActiveRecord::Base
|
||||
|
||||
after_save :save_predecessors
|
||||
|
||||
# relations
|
||||
belongs_to :context
|
||||
belongs_to :project
|
||||
belongs_to :user
|
||||
|
|
@ -13,20 +16,17 @@ class Todo < ActiveRecord::Base
|
|||
:source => :predecessor, :conditions => ['NOT (todos.state = ?)', 'completed']
|
||||
has_many :pending_successors, :through => :predecessor_dependencies,
|
||||
:source => :successor, :conditions => ['todos.state = ?', 'pending']
|
||||
|
||||
after_save :save_predecessors
|
||||
|
||||
# scopes for states of this todo
|
||||
named_scope :active, :conditions => { :state => 'active' }
|
||||
named_scope :active_or_hidden, :conditions => ["todos.state = ? OR todos.state = ?", 'active', 'project_hidden']
|
||||
named_scope :not_completed, :conditions => ['NOT (todos.state = ? )', 'completed']
|
||||
named_scope :completed, :conditions => ["NOT(todos.completed_at IS NULL)"]
|
||||
named_scope :are_due, :conditions => ['NOT (todos.due IS NULL)']
|
||||
named_scope :deferred, :conditions => ["todos.completed_at IS NULL AND NOT(todos.show_from IS NULL)"]
|
||||
named_scope :not_completed, :conditions => ['NOT (todos.state = ?)', 'completed']
|
||||
named_scope :completed, :conditions => ["NOT (todos.completed_at IS NULL)"]
|
||||
named_scope :deferred, :conditions => ["todos.completed_at IS NULL AND NOT (todos.show_from IS NULL)"]
|
||||
named_scope :blocked, :conditions => ['todos.state = ?', 'pending']
|
||||
named_scope :pending, :conditions => ['todos.state = ?', 'pending']
|
||||
named_scope :deferred_or_blocked, :conditions => ["(todos.completed_at IS NULL AND NOT(todos.show_from IS NULL)) OR (todos.state = ?)", "pending"]
|
||||
named_scope :not_deferred_or_blocked, :conditions => ["todos.completed_at IS NULL AND todos.show_from IS NULL AND NOT(todos.state = ?)", "pending"]
|
||||
named_scope :with_tag, lambda { |tag| {:joins => :taggings, :conditions => ["taggings.tag_id = ? ", tag.id] } }
|
||||
named_scope :of_user, lambda { |user_id| {:conditions => ["todos.user_id = ? ", user_id] } }
|
||||
named_scope :hidden,
|
||||
:joins => :context,
|
||||
:conditions => ["todos.state = ? OR (contexts.hide = ? AND (todos.state = ? OR todos.state = ? OR todos.state = ?))",
|
||||
|
|
@ -36,6 +36,13 @@ class Todo < ActiveRecord::Base
|
|||
:conditions => ['NOT(todos.state = ? OR (contexts.hide = ? AND (todos.state = ? OR todos.state = ? OR todos.state = ?)))',
|
||||
'project_hidden', true, 'active', 'deferred', 'pending']
|
||||
|
||||
# other scopes
|
||||
named_scope :are_due, :conditions => ['NOT (todos.due IS NULL)']
|
||||
named_scope :with_tag, lambda { |tag| {:joins => :taggings, :conditions => ["taggings.tag_id = ? ", tag.id] } }
|
||||
named_scope :of_user, lambda { |user_id| {:conditions => ["todos.user_id = ? ", user_id] } }
|
||||
named_scope :completed_after, lambda { |date| {:conditions => ["todos.completed_at > ? ", date] } }
|
||||
named_scope :completed_before, lambda { |date| {:conditions => ["todos.completed_at < ? ", date] } }
|
||||
|
||||
STARRED_TAG_NAME = "starred"
|
||||
|
||||
# regular expressions for dependencies
|
||||
|
|
@ -302,7 +309,7 @@ class Todo < ActiveRecord::Base
|
|||
|
||||
context_id = default_context_id
|
||||
unless(context.nil?)
|
||||
found_context = user.active_contexts.find_by_namepart(context)
|
||||
found_context = user.contexts.active.find_by_namepart(context)
|
||||
found_context = user.contexts.find_by_namepart(context) if found_context.nil?
|
||||
context_id = found_context.id unless found_context.nil?
|
||||
end
|
||||
|
|
@ -318,7 +325,7 @@ class Todo < ActiveRecord::Base
|
|||
found_project.name = project[4..255+4].strip
|
||||
found_project.save!
|
||||
else
|
||||
found_project = user.active_projects.find_by_namepart(project)
|
||||
found_project = user.projects.active.find_by_namepart(project)
|
||||
found_project = user.projects.find_by_namepart(project) if found_project.nil?
|
||||
end
|
||||
project_id = found_project.id unless found_project.nil?
|
||||
|
|
|
|||
|
|
@ -79,19 +79,9 @@ class User < ActiveRecord::Base
|
|||
return find(:all, :conditions => scope_conditions)
|
||||
end
|
||||
end
|
||||
has_many :active_projects,
|
||||
:class_name => 'Project',
|
||||
:order => 'projects.position ASC',
|
||||
:conditions => [ 'state = ?', 'active' ]
|
||||
has_many :active_contexts,
|
||||
:class_name => 'Context',
|
||||
:order => 'position ASC',
|
||||
:conditions => [ 'hide = ?', false ]
|
||||
has_many :todos,
|
||||
:order => 'todos.completed_at DESC, todos.created_at DESC',
|
||||
:dependent => :delete_all
|
||||
has_many :project_hidden_todos,
|
||||
:conditions => ['(state = ? OR state = ?)', 'project_hidden', 'active']
|
||||
has_many :recurring_todos,
|
||||
:order => 'recurring_todos.completed_at DESC, recurring_todos.created_at DESC',
|
||||
:dependent => :delete_all
|
||||
|
|
@ -103,23 +93,6 @@ class User < ActiveRecord::Base
|
|||
find(:all, :conditions => ['show_from <= ?', Time.zone.now ]).collect { |t| t.activate! }
|
||||
end
|
||||
end
|
||||
has_many :pending_todos,
|
||||
:class_name => 'Todo',
|
||||
:conditions => [ 'state = ?', 'pending' ],
|
||||
:order => 'show_from ASC, todos.created_at DESC'
|
||||
has_many :completed_todos,
|
||||
:class_name => 'Todo',
|
||||
:conditions => ['todos.state = ? AND NOT(todos.completed_at IS NULL)', 'completed'],
|
||||
:order => 'todos.completed_at DESC',
|
||||
:include => [ :project, :context ] do
|
||||
def completed_within( date )
|
||||
reject { |x| x.completed_at < date }
|
||||
end
|
||||
|
||||
def completed_more_than( date )
|
||||
reject { |x| x.completed_at > date }
|
||||
end
|
||||
end
|
||||
has_many :notes, :order => "created_at DESC", :dependent => :delete_all
|
||||
has_one :preference, :dependent => :destroy
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
<div id="display_box_projects">
|
||||
<p><%= t('todos.completed_today', :count => @due_tickles.nil? ? 0 : @due_tickles.length) %></p>
|
||||
<div class="container">
|
||||
<h2><%= t('todos.completed_last_day') %></h2>
|
||||
<table class="next_actions" border="0">
|
||||
<%= render :partial => "done", :collection => @done_today %>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<h2><%= t('todos.completed_last_x_days', :count => 7) %></h2>
|
||||
<table class="next_actions" border="0">
|
||||
<%= render :partial => "done", :collection => @done_this_week %>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<h2><%= t('todos.completed_last_x_days', :count => 28) %></h2>
|
||||
<table class="next_actions" border="0">
|
||||
<%= render :partial => "done", :collection => @done_this_month %>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p><%= t('todos.older_completed_items') %>: <%= link_to( t('todos.older_than_days', :count => 31), done_archive_path ) %></p>
|
||||
</div><!-- End of display_box -->
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<div id="display_box_projects">
|
||||
|
||||
<p><%= t('todos.completed_in_archive', :count => @done_archive.length) %></p>
|
||||
<div class="container">
|
||||
<h2><%= t('todos.completed_more_than_x_days_ago', :count => 31) %></h2>
|
||||
<table class="next_actions" cellspacing="5" cellpadding="0" border="0">
|
||||
<%= render :partial => "done", :collection => @done_archive %>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div><!-- End of display_box -->
|
||||
39
app/views/todos/done.html.erb
Normal file
39
app/views/todos/done.html.erb
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<div id="display_box_projects">
|
||||
<div class="container">
|
||||
<h2><%= t('todos.completed_today') %></h2>
|
||||
<% if @done_today.empty? -%>
|
||||
<div class="message"><p><%= t('todos.no_completed_actions') %></p></div>
|
||||
<% else -%>
|
||||
<%= render :partial => "todos/todo", :collection => @done_today, :locals => { :parent_container_type => "completed", :suppress_context => false, :suppress_project => false } %>
|
||||
<% end -%>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<h2><%= t('todos.completed_rest_of_week') %></h2>
|
||||
<% if @done_this_week.empty? -%>
|
||||
<div class="message"><p><%= t('todos.no_completed_actions') %></p></div>
|
||||
<% else -%>
|
||||
<%= render :partial => "todos/todo", :collection => @done_this_week, :locals => { :parent_container_type => "completed", :suppress_context => false, :suppress_project => false } %>
|
||||
<% end -%>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<h2><%= t('todos.completed_rest_of_month', :month_name => 'TODO') %></h2>
|
||||
<% if @done_this_month.empty? -%>
|
||||
<div class="message"><p><%= t('todos.no_completed_actions') %></p></div>
|
||||
<% else -%>
|
||||
<%= render :partial => "todos/todo", :collection => @done_this_month, :locals => { :parent_container_type => "completed", :suppress_context => false, :suppress_project => false } %>
|
||||
<% end -%>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<h2><%= t('todos.completed_rest_of_previous_month', :month_name => 'TODO2') %></h2>
|
||||
<% if @done_previous_month.empty? -%>
|
||||
<div class="message"><p><%= t('todos.no_completed_actions') %></p></div>
|
||||
<% else -%>
|
||||
<%= render :partial => "todos/todo", :collection => @done_previous_month, :locals => { :parent_container_type => "completed", :suppress_context => false, :suppress_project => false } %>
|
||||
<% end -%>
|
||||
</div>
|
||||
|
||||
|
||||
</div><!-- End of display_box -->
|
||||
|
|
@ -656,17 +656,10 @@ en:
|
|||
tickler_items_due:
|
||||
one: "One tickler item is now due - refresh the page to see it."
|
||||
other: "%{count} tickler items are now due - refresh the page to see them."
|
||||
completed_today:
|
||||
one: "You have completed one action so far today."
|
||||
other: "You have completed %{count} actions so far today."
|
||||
completed_last_day: "Completed in the last 24 hours"
|
||||
completed_last_x_days: "Completed in last %{count} days"
|
||||
older_completed_items: "Older completed items"
|
||||
older_than_days: "Older than %{count} days"
|
||||
completed_in_archive:
|
||||
one: "There is one completed action in the archive."
|
||||
other: "There are %{count} completed actions in the archive."
|
||||
completed_more_than_x_days_ago: "Completed more than %{count} days ago"
|
||||
completed_today: "Completed today"
|
||||
completed_rest_of_week: "Completed in the rest of this week"
|
||||
completed_rest_of_month: "Completed in the rest of this month"
|
||||
completed_rest_of_previous_month: "Completed in the rest of the previous month"
|
||||
added_new_next_action: "Added new next action"
|
||||
added_new_next_action_singular: "Added new next action"
|
||||
added_new_next_action_plural: "Added new next actions"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ ActionController::Routing::Routes.draw do |map|
|
|||
:member => {:change_password => :get, :update_password => :post,
|
||||
:change_auth_type => :get, :update_auth_type => :post, :complete => :get,
|
||||
:refresh_token => :post }
|
||||
map.with_options :controller => "users" do |users|
|
||||
|
||||
map.with_options :controller => :users do |users|
|
||||
users.signup 'signup', :action => "new"
|
||||
end
|
||||
|
||||
|
|
@ -11,21 +12,28 @@ ActionController::Routing::Routes.draw do |map|
|
|||
contexts.resources :todos, :name_prefix => "context_"
|
||||
end
|
||||
|
||||
map.with_options :controller => :contexts do |contexts|
|
||||
contexts.done 'contexts/done', :action => 'completed'
|
||||
end
|
||||
|
||||
map.resources :projects, :collection => {:order => :post, :alphabetize => :post, :actionize => :post} do |projects|
|
||||
projects.resources :todos, :name_prefix => "project_"
|
||||
end
|
||||
|
||||
map.with_options :controller => :projects do |projects|
|
||||
projects.done 'projects/done', :action => 'completed'
|
||||
end
|
||||
|
||||
map.resources :notes
|
||||
|
||||
map.resources :todos,
|
||||
:member => {:toggle_check => :put, :toggle_star => :put},
|
||||
:collection => {:check_deferred => :post, :filter_to_context => :post, :filter_to_project => :post}
|
||||
map.with_options :controller => "todos" do |todos|
|
||||
:collection => {:check_deferred => :post, :filter_to_context => :post, :filter_to_project => :post, :done => :get}
|
||||
|
||||
map.with_options :controller => :todos do |todos|
|
||||
todos.home '', :action => "index"
|
||||
todos.tickler 'tickler', :action => "list_deferred"
|
||||
todos.mobile_tickler 'tickler.m', :action => "list_deferred", :format => 'm'
|
||||
todos.done 'done', :action => "completed"
|
||||
todos.done_archive 'done/archive', :action => "completed_archive"
|
||||
|
||||
# This route works for tags with dots like /todos/tag/version1.5
|
||||
# please note that this pattern consumes everything after /todos/tag
|
||||
|
|
@ -78,6 +86,7 @@ ActionController::Routing::Routes.draw do |map|
|
|||
map.stats 'stats', :controller => 'stats', :action => 'index'
|
||||
map.search 'search', :controller => 'search', :action => 'index'
|
||||
map.data 'data', :controller => 'data', :action => 'index'
|
||||
map.done 'done', :controller => 'todos', :action => 'completed_overview'
|
||||
|
||||
map.connect '/selenium_helper/login', :controller => 'selenium_helper', :action => 'login' if Rails.env == 'test'
|
||||
Translate::Routes.translation_ui(map) if Rails.env != "production"
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
|
|||
assert_not_nil assigns['deferred']
|
||||
assert_equal 1, assigns['deferred'].size
|
||||
|
||||
t = p.not_done_todos[0]
|
||||
t = p.todos.not_completed[0]
|
||||
t.show_from = 1.days.from_now.utc
|
||||
t.save!
|
||||
|
||||
|
|
|
|||
|
|
@ -99,14 +99,6 @@ class ContextTest < ActiveSupport::TestCase
|
|||
assert_equal true, @agenda.hidden?
|
||||
end
|
||||
|
||||
def test_summary
|
||||
undone_todo_count = '5 actions'
|
||||
assert_equal "<p>#{undone_todo_count}. Context is Active.</p>", @agenda.summary(undone_todo_count)
|
||||
@agenda.hide = true
|
||||
@agenda.save!
|
||||
assert_equal "<p>#{undone_todo_count}. Context is Hidden.</p>", @agenda.summary(undone_todo_count)
|
||||
end
|
||||
|
||||
def test_null_object
|
||||
c = Context.null_object
|
||||
assert c.nil?
|
||||
|
|
|
|||
|
|
@ -100,27 +100,27 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_not_done_todos
|
||||
assert_equal 2, @timemachine.not_done_todos.size
|
||||
t = @timemachine.not_done_todos[0]
|
||||
assert_equal 3, @timemachine.todos.not_completed.size
|
||||
t = @timemachine.todos.not_completed[0]
|
||||
t.complete!
|
||||
t.save!
|
||||
assert_equal 1, Project.find(@timemachine.id).not_done_todos.size
|
||||
assert_equal 2, Project.find(@timemachine.id).todos.not_completed.size
|
||||
end
|
||||
|
||||
def test_done_todos
|
||||
assert_equal 0, @timemachine.done_todos.size
|
||||
t = @timemachine.not_done_todos[0]
|
||||
assert_equal 0, @timemachine.todos.completed.size
|
||||
t = @timemachine.todos.not_completed[0]
|
||||
t.complete!
|
||||
t.save!
|
||||
assert_equal 1, Project.find(@timemachine.id).done_todos.size
|
||||
assert_equal 1, Project.find(@timemachine.id).todos.completed.size
|
||||
end
|
||||
|
||||
def test_deferred_todos
|
||||
assert_equal 1, @timemachine.deferred_todos.size
|
||||
t = @timemachine.not_done_todos[0]
|
||||
assert_equal 1, @timemachine.todos.deferred.size
|
||||
t = @timemachine.todos.not_completed[0]
|
||||
t.show_from = 1.days.from_now.utc
|
||||
t.save!
|
||||
assert_equal 2, Project.find(@timemachine.id).deferred_todos.size
|
||||
assert_equal 2, Project.find(@timemachine.id).todos.deferred.size
|
||||
end
|
||||
|
||||
def test_to_param_returns_id
|
||||
|
|
@ -157,25 +157,28 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_deferred_todo_count
|
||||
assert_equal 1, @timemachine.deferred_todos.count
|
||||
assert_equal 0, @moremoney.deferred_todos.count
|
||||
@moremoney.todos[0].show_from = next_week
|
||||
assert_equal 1, @timemachine.todos.deferred.count
|
||||
assert_equal 0, @moremoney.todos.deferred.count
|
||||
|
||||
first_todo = @moremoney.todos[0]
|
||||
first_todo.show_from = next_week
|
||||
assert_equal :deferred, @moremoney.todos[0].aasm_current_state
|
||||
assert_equal 1, @moremoney.deferred_todos.count
|
||||
|
||||
assert_equal 1, @moremoney.todos.deferred.count
|
||||
end
|
||||
|
||||
def test_done_todo_count
|
||||
assert_equal 0, @timemachine.done_todos.count
|
||||
assert_equal 0, @moremoney.done_todos.count
|
||||
assert_equal 0, @timemachine.todos.completed.count
|
||||
assert_equal 0, @moremoney.todos.completed.count
|
||||
@moremoney.todos[0].complete!
|
||||
assert_equal 1, @moremoney.done_todos.count
|
||||
assert_equal 1, @moremoney.todos.completed.count
|
||||
end
|
||||
|
||||
def test_not_done_todo_count
|
||||
assert_equal 2, @timemachine.not_done_todos.count
|
||||
assert_equal 4, @moremoney.not_done_todos.count
|
||||
assert_equal 3, @timemachine.todos.not_completed.count
|
||||
assert_equal 4, @moremoney.todos.not_completed.count
|
||||
@moremoney.todos[0].complete!
|
||||
assert_equal 3, @moremoney.not_done_todos.count
|
||||
assert_equal 3, @moremoney.todos.not_completed.count
|
||||
end
|
||||
|
||||
def test_default_context_name
|
||||
|
|
|
|||
7
test/views/context_helper_test.rb
Normal file
7
test/views/context_helper_test.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
def test_summary
|
||||
undone_todo_count = '5 actions'
|
||||
assert_equal "<p>#{undone_todo_count}. Context is Active.</p>", @agenda.summary(undone_todo_count)
|
||||
@agenda.hide = true
|
||||
@agenda.save!
|
||||
assert_equal "<p>#{undone_todo_count}. Context is Hidden.</p>", @agenda.summary(undone_todo_count)
|
||||
end
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class TodosHelperTest < Test::Rails::HelperTestCase
|
||||
class TodosHelperTest < ActiveSupport::HelperTestCase
|
||||
fixtures :users
|
||||
|
||||
def setup
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue