Fixed an error when clicking new "star" item in navigation before any items have been starred. Closes #573.

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@604 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2007-09-30 12:47:06 +00:00
parent 6eb7e06e1b
commit 7d40e48230
3 changed files with 16 additions and 14 deletions

View file

@ -294,24 +294,20 @@ class TodosController < ApplicationController
#
def tag
@tag = tag_name = params[:name]
if Tag.find_by_name(tag_name).nil?
# TODO: This doesn't work - you get kicked back to the index
# with a generic "Error occured on the server error"
notify :error, "Tag \'#{@tag}\' does not exist", 2.0
@not_done_todos = []
else
tag_collection = Tag.find_by_name(tag_name).todos
@not_done_todos = tag_collection.find(:all, :conditions => ['taggings.user_id = ? and state = ?', current_user.id, 'active'])
@tag_name = params[:name]
@tag = Tag.find_by_name(@tag_name)
if @tag.nil?
@tag = Tag.new(:name => @tag_name)
end
tag_collection = @tag.todos
@not_done_todos = tag_collection.find(:all, :conditions => ['taggings.user_id = ? and state = ?', current_user.id, 'active'])
@contexts = current_user.contexts.find(:all, :include => [ :todos ])
@contexts_to_show = @contexts.reject {|x| x.hide? }
@deferred = tag_collection.find(:all, :conditions => ['taggings.user_id = ? and state = ?', current_user.id, 'deferred'])
@page_title = "TRACKS::Tagged with \'#{@tag}\'"
@page_title = "TRACKS::Tagged with \'#{@tag_name}\'"
# If you've set no_completed to zero, the completed items box
# isn't shown on the home page
max_completed = current_user.prefs.show_number_completed

View file

@ -3,19 +3,19 @@
<h2>
No actions found
</h2>
<div class="message"><p>Currently there are no incomplete actions with the tag '<%= @tag %>'</p></div>
<div class="message"><p>Currently there are no incomplete actions with the tag '<%= @tag_name %>'</p></div>
</div>
<%= render :partial => "contexts/context", :collection => @contexts_to_show,
:locals => { :collapsible => true } %>
<% unless @deferred.nil? -%>
<%= render :partial => "todos/deferred", :locals => { :deferred => @deferred, :collapsible => true, :append_descriptor => "tagged with &lsquo;#{@tag}&rsquo;" } %>
<%= render :partial => "todos/deferred", :locals => { :deferred => @deferred, :collapsible => true, :append_descriptor => "tagged with &lsquo;#{@tag_name}&rsquo;" } %>
<% end -%>
<% unless @done.nil? -%>
<%= render :partial => "todos/completed",
:locals => { :done => @done, :collapsible => true, :append_descriptor => "tagged with &lsquo;#{@tag}&rsquo;" } %>
:locals => { :done => @done, :collapsible => true, :append_descriptor => "tagged with &lsquo;#{@tag_name}&rsquo;" } %>
<% end -%>
</div><!-- End of display_box -->

View file

@ -0,0 +1,6 @@
setup :fixtures => [:users, :projects, :contexts, :todos, :notes]
login :as => 'admin'
open "/"
click_and_wait "xpath=//ul[@id='navlist'] //a[@title='See your starred actions']"
assert_title "exact:TRACKS::Tagged with 'starred'"
verify_text_present "Currently there are no incomplete actions with the tag 'starred'"