diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 7f021d80..61aee981 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -648,7 +648,7 @@ class TodosController < ApplicationController @tag = Tag.find_by_name(@tag_name) @tag = Tag.new(:name => @tag_name) if @tag.nil? - completed_todos = current_user.todos.completed.with_tag(@tag) + completed_todos = current_user.todos.completed.with_tag(@tag.id) @done_today = get_done_today(completed_todos) @done_this_week = get_done_this_week(completed_todos) @@ -665,7 +665,7 @@ class TodosController < ApplicationController @tag = Tag.find_by_name(@tag_name) @tag = Tag.new(:name => @tag_name) if @tag.nil? - @done = current_user.todos.completed.with_tag(@tag).paginate :page => params[:page], :per_page => 20, :order => 'completed_at DESC', :include => Todo::DEFAULT_INCLUDES + @done = current_user.todos.completed.with_tag(@tag.id).paginate :page => params[:page], :per_page => 20, :order => 'completed_at DESC', :include => Todo::DEFAULT_INCLUDES @count = @done.size render :template => 'todos/all_done' end @@ -1029,7 +1029,11 @@ class TodosController < ApplicationController def find_todos_with_tag_expr(tag_expr) # optimize for the common case: selecting only one tag - return current_user.todos.with_tag(@tag_name) if @single_tag + if @single_tag + tag = Tag.find_by_name(@tag_name) + tag_id = tag.nil? ? -1 : tag.id + return current_user.todos.with_tag(tag_id) + end tag_ids = get_ids_from_tag_expr(tag_expr) todos = current_user.todos @@ -1070,7 +1074,7 @@ class TodosController < ApplicationController if @tag.nil? @tag = Tag.new(:name => @tag_name) end - @down_count = current_user.todos.with_tag(@tag).active.not_hidden.count + @down_count = current_user.todos.with_tag(@tag.id).active.not_hidden.count end end end @@ -1087,10 +1091,10 @@ class TodosController < ApplicationController if tag.nil? tag = Tag.new(:name => params['tag']) end - @remaining_deferred_or_pending_count = current_user.todos.with_tag(tag).deferred_or_blocked.count - @remaining_in_context = current_user.contexts.find(context_id).todos.active.not_hidden.with_tag(tag).count - @target_context_count = current_user.contexts.find(@todo.context_id).todos.active.not_hidden.with_tag(tag).count - @remaining_hidden_count = current_user.todos.hidden.with_tag(tag).count + @remaining_deferred_or_pending_count = current_user.todos.with_tag(tag.id).deferred_or_blocked.count + @remaining_in_context = current_user.contexts.find(context_id).todos.active.not_hidden.with_tag(tag.id).count + @target_context_count = current_user.contexts.find(@todo.context_id).todos.active.not_hidden.with_tag(tag.id).count + @remaining_hidden_count = current_user.todos.hidden.with_tag(tag.id).count } from.project { project_id = @project_changed ? @original_item_project_id : @todo.project_id @@ -1141,7 +1145,7 @@ class TodosController < ApplicationController end end from.tag do - @completed_count = current_user.todos.with_tag(@tag).completed.count + @completed_count = current_user.todos.with_tag(@tag.id).completed.count end end end @@ -1149,7 +1153,7 @@ class TodosController < ApplicationController def determine_deferred_tag_count(tag_name) tag = Tag.find_by_name(tag_name) # tag.nil? should normally not happen, but is a workaround for #929 - @remaining_deferred_or_pending_count = tag.nil? ? 0 : current_user.todos.deferred.with_tag(tag).count + @remaining_deferred_or_pending_count = tag.nil? ? 0 : current_user.todos.deferred.with_tag(tag.id).count end def render_todos_html diff --git a/app/models/todo.rb b/app/models/todo.rb index 45253ab3..06b23699 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -38,7 +38,7 @@ class Todo < ActiveRecord::Base # 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 :with_tag, lambda { |tag_id| {:joins => :taggings, :conditions => ["taggings.tag_id = ? ", tag_id] } } named_scope :with_tags, lambda { |tag_ids| {:conditions => ["EXISTS(SELECT * from taggings t WHERE t.tag_id IN (?) AND t.taggable_id=todos.id AND t.taggable_type='Todo')", tag_ids] } } named_scope :of_user, lambda { |user_id| {:conditions => ["todos.user_id = ? ", user_id] } } named_scope :completed_after, lambda { |date| {:conditions => ["todos.completed_at > ? ", date] } } diff --git a/config/routes.rb b/config/routes.rb index 533ca270..ec0ed738 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -40,7 +40,7 @@ ActionController::Routing::Routes.draw do |map| # UPDATE: added support for mobile view. All tags ending on .m will be # routed to mobile view of tags. todos.mobile_tag 'todos/tag/:name.m', :action => "tag", :format => 'm' - todos.mobile_tag 'todos/tag/:name.txt', :action => "tag", :format => 'txt' + todos.text_tag 'todos/tag/:name.txt', :action => "tag", :format => 'txt' todos.tag 'todos/tag/:name', :action => "tag", :name => /.*/ todos.done_tag 'todos/done/tag/:name', :action => "done_tag" todos.all_done_tag 'todos/all_done/tag/:name', :action => "all_done_tag" diff --git a/features/shared_add_new_todo.feature b/features/shared_add_new_todo.feature index 11f1cc65..8e48d567 100644 --- a/features/shared_add_new_todo.feature +++ b/features/shared_add_new_todo.feature @@ -95,7 +95,7 @@ Feature: Add new next action from every page | tickler page | not see | | "test project" project | see | | context page for "test context" | see | - | tag page for "starred" | not see | + | tag page for "starred" | see | @selenium Scenario Outline: I can add multiple todos from several pages diff --git a/test/functional/todos_controller_test.rb b/test/functional/todos_controller_test.rb index 20b3c7a5..e8003eac 100644 --- a/test/functional/todos_controller_test.rb +++ b/test/functional/todos_controller_test.rb @@ -492,7 +492,7 @@ class TodosControllerTest < ActionController::TestCase recurring_todo_1 = RecurringTodo.find(1) set_user_to_current_time_zone(recurring_todo_1.user) todo_1 = Todo.find_by_recurring_todo_id(1) - today = Time.now.at_midnight + today = Time.zone.now.at_midnight # change recurrence pattern to monthly and set show_from to today recurring_todo_1.target = 'show_from_date' @@ -650,6 +650,7 @@ class TodosControllerTest < ActionController::TestCase get :tag, :name => "single" assert_equal true, assigns['single_tag'], "should recognize it is a single tag name" assert_equal "single", assigns['tag_expr'][0][0], "should store the single tag" + assert_equal "single", assigns['tag_name'], "should store the single tag name" end def test_get_boolean_expression_from_parameters_of_tag_view_multiple_tags