diff --git a/tracks/app/controllers/todos_controller.rb b/tracks/app/controllers/todos_controller.rb index 2adaf02c..1b1dc760 100644 --- a/tracks/app/controllers/todos_controller.rb +++ b/tracks/app/controllers/todos_controller.rb @@ -341,7 +341,6 @@ class TodosController < ApplicationController end condition_builder = FindConditionBuilder.new - options = Hash.new if params.key?('done') condition_builder.add 'todos.state = ?', 'completed' @@ -368,7 +367,7 @@ class TodosController < ApplicationController @title << " actions completed" @description << " in the last #{done_in_last.to_s} days" end - + Todo.with_scope :find => {:conditions => condition_builder.to_conditions} do yield end @@ -393,10 +392,16 @@ class TodosController < ApplicationController def with_limit_scope(&block) if params.key?('limit') - Todo.with_scope :find => {:limit => params['limit']} do + Todo.with_scope :find => { :limit => params['limit'] } do yield end - #@description = limit ? "Lists the last #{limit} incomplete next actions" : "Lists incomplete next actions" + if TodosController.is_feed_request(request) && @description + if params.key?('limit') + @description << "Lists the last #{params['limit']} incomplete next actions" + else + @description << "Lists incomplete next actions" + end + end else yield end @@ -419,11 +424,13 @@ class TodosController < ApplicationController else + # Note: these next two finds were previously using @users.todos.find but that broke with_scope for :limit + # Exclude hidden projects from count on home page - @todos = @user.todos.find(:all, :conditions => ['todos.state = ? or todos.state = ?', 'active', 'completed'], :include => [ :project, :context, :tags ]) + @todos = Todo.find(:all, :conditions => ['todos.user_id = ? and todos.state = ? or todos.state = ?', @user.id, 'active', 'completed'], :include => [ :project, :context, :tags ]) # Exclude hidden projects from the home page - @not_done_todos = @user.todos.find(:all, :conditions => ['todos.state = ?', 'active'], :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC", :include => [ :project, :context, :tags ]) + @not_done_todos = Todo.find(:all, :conditions => ['todos.user_id = ? and todos.state = ?', @user.id, 'active'], :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC", :include => [ :project, :context, :tags ]) end diff --git a/tracks/test/functional/todos_controller_test.rb b/tracks/test/functional/todos_controller_test.rb index 8867df8b..434af7d6 100644 --- a/tracks/test/functional/todos_controller_test.rb +++ b/tracks/test/functional/todos_controller_test.rb @@ -140,8 +140,8 @@ class TodosControllerTest < Test::Rails::TestCase assert_response :success assert_equal 3, @tagged end - - def test_find_tagged_withd_content + + def test_rss_feed @request.session['user_id'] = users(:admin_user).id get :index, { :format => "rss" } assert_equal 'application/rss+xml; charset=utf-8', @response.headers["Content-Type"] @@ -165,6 +165,22 @@ class TodosControllerTest < Test::Rails::TestCase end end + def test_rss_feed_with_limit + @request.session['user_id'] = users(:admin_user).id + get :index, { :format => "rss", :limit => '5' } + + assert_xml_select 'rss[version="2.0"]' do + assert_select 'channel' do + assert_select '>title', 'Tracks Actions' + assert_select '>description', "Actions for #{users(:admin_user).display_name}" + assert_select 'item', 5 do + assert_select 'title', /.+/ + assert_select 'description', /.*/ + end + end + end + end + def test_rss_feed_not_accessible_to_anonymous_user_without_token @request.session['user_id'] = nil get :index, { :format => "rss" }