Index: trunk/app/controllers/auto_completes_controller.rb
===================================================================
--- trunk/app/controllers/auto_completes_controller.rb	(nonexistent)
+++ trunk/app/controllers/auto_completes_controller.rb	(revision 3945)
@@ -0,0 +1,25 @@
+class AutoCompletesController < ApplicationController
+  before_filter :find_project
+  
+  def issues
+    @issues = []
+    q = params[:q].to_s
+    if q.match(/^\d+$/)
+      @issues << @project.issues.visible.find_by_id(q.to_i)
+    end
+    unless q.blank?
+      @issues += @project.issues.visible.find(:all, :conditions => ["LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%"], :limit => 10)
+    end
+    render :layout => false
+  end
+
+  private
+
+  def find_project
+    project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
+    @project = Project.find(project_id)
+  rescue ActiveRecord::RecordNotFound
+    render_404
+  end
+
+end
Index: trunk/app/controllers/issues_controller.rb
===================================================================
--- trunk/app/controllers/issues_controller.rb	(revision 3944)
+++ trunk/app/controllers/issues_controller.rb	(revision 3945)
@@ -21,7 +21,7 @@
   
   before_filter :find_issue, :only => [:show, :edit, :update]
   before_filter :find_issues, :only => [:bulk_edit, :move, :perform_move, :destroy]
-  before_filter :find_project, :only => [:new, :create, :update_form, :preview, :auto_complete]
+  before_filter :find_project, :only => [:new, :create, :update_form, :preview]
   before_filter :authorize, :except => [:index, :changes, :preview, :context_menu]
   before_filter :find_optional_project, :only => [:index, :changes]
   before_filter :check_for_default_issue_status, :only => [:new, :create]
@@ -316,18 +316,6 @@
     render :layout => false
   end
   
-  def auto_complete
-    @issues = []
-    q = params[:q].to_s
-    if q.match(/^\d+$/)
-      @issues << @project.issues.visible.find_by_id(q.to_i)
-    end
-    unless q.blank?
-      @issues += @project.issues.visible.find(:all, :conditions => ["LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%"], :limit => 10)
-    end
-    render :layout => false
-  end
-  
 private
   def find_issue
     @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
Index: trunk/app/views/auto_completes/issues.html.erb
===================================================================
--- trunk/app/views/auto_completes/issues.html.erb	(nonexistent)
+++ trunk/app/views/auto_completes/issues.html.erb	(revision 3945)
@@ -0,0 +1,9 @@
+<ul>
+<% if @issues.any? -%>
+  <% @issues.each do |issue| -%>
+    <%= content_tag 'li', h("#{issue.tracker} ##{issue.id}: #{issue.subject}"), :id => issue.id %>
+  <% end -%>
+<% else -%>
+  <%= content_tag("li", l(:label_none), :style => 'display:none') %>
+<% end -%>
+</ul>

Property changes on: trunk/app/views/auto_completes/issues.html.erb
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: trunk/app/views/issues/auto_complete.html.erb
===================================================================
--- trunk/app/views/issues/auto_complete.html.erb	(revision 3944)
+++ trunk/app/views/issues/auto_complete.html.erb	(nonexistent)
@@ -1,9 +0,0 @@
-<ul>
-<% if @issues.any? -%>
-  <% @issues.each do |issue| -%>
-    <%= content_tag 'li', h("#{issue.tracker} ##{issue.id}: #{issue.subject}"), :id => issue.id %>
-  <% end -%>
-<% else -%>
-  <%= content_tag("li", l(:label_none), :style => 'display:none') %>
-<% end -%>
-</ul>

Property changes on: trunk/app/views/issues/auto_complete.html.erb
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Index: trunk/app/views/issues/_form.rhtml
===================================================================
--- trunk/app/views/issues/_form.rhtml	(revision 3944)
+++ trunk/app/views/issues/_form.rhtml	(revision 3945)
@@ -9,10 +9,7 @@
 <% unless (@issue.new_record? && @issue.parent_issue_id.nil?) || !User.current.allowed_to?(:manage_subtasks, @project) %>
 <p><%= f.text_field :parent_issue_id, :size => 10 %></p>
 <div id="parent_issue_candidates" class="autocomplete"></div>
-<%= javascript_tag "observeParentIssueField('#{url_for(:controller => :issues,
-                                                       :action => :auto_complete,
-                                                       :id => @issue,
-                                                       :project_id => @project) }')" %>
+<%= javascript_tag "observeParentIssueField('#{auto_complete_issues_path(:id => @issue, :project_id => @project) }')" %>
 <% end %>
 
 <p><%= f.text_area :description,
Index: trunk/config/routes.rb
===================================================================
--- trunk/config/routes.rb	(revision 3944)
+++ trunk/config/routes.rb	(revision 3945)
@@ -104,7 +104,8 @@
   end
 
   map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move'
-
+  map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues'
+  
   map.with_options :controller => 'issues' do |issues_routes|
     issues_routes.with_options :conditions => {:method => :get} do |issues_views|
       issues_views.connect 'issues', :action => 'index'
Index: trunk/lib/redmine.rb
===================================================================
--- trunk/lib/redmine.rb	(revision 3944)
+++ trunk/lib/redmine.rb	(revision 3945)
@@ -58,7 +58,8 @@
     map.permission :manage_categories, {:projects => :settings, :issue_categories => [:new, :edit, :destroy]}, :require => :member
     # Issues
     map.permission :view_issues, {:projects => :roadmap, 
-                                  :issues => [:index, :changes, :show, :context_menu, :auto_complete],
+                                  :issues => [:index, :changes, :show, :context_menu],
+                                  :auto_complete => [:issues],
                                   :versions => [:show, :status_by],
                                   :queries => :index,
                                   :reports => [:issue_report, :issue_report_details]}
Index: trunk/test/functional/auto_completes_controller_test.rb
===================================================================
--- trunk/test/functional/auto_completes_controller_test.rb	(nonexistent)
+++ trunk/test/functional/auto_completes_controller_test.rb	(revision 3945)
@@ -0,0 +1,20 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class AutoCompletesControllerTest < ActionController::TestCase
+  fixtures :all
+
+  def test_issues_should_not_be_case_sensitive
+    get :issues, :project_id => 'ecookbook', :q => 'ReCiPe'
+    assert_response :success
+    assert_not_nil assigns(:issues)
+    assert assigns(:issues).detect {|issue| issue.subject.match /recipe/}
+  end
+  
+  def test_issues_should_return_issue_with_given_id
+    get :issues, :project_id => 'subproject1', :q => '13'
+    assert_response :success
+    assert_not_nil assigns(:issues)
+    assert assigns(:issues).include?(Issue.find(13))
+  end
+  
+end
Index: trunk/test/functional/issues_controller_test.rb
===================================================================
--- trunk/test/functional/issues_controller_test.rb	(revision 3944)
+++ trunk/test/functional/issues_controller_test.rb	(revision 3945)
@@ -1123,20 +1123,6 @@
     assert_not_nil assigns(:notes)
   end
 
-  def test_auto_complete_should_not_be_case_sensitive
-    get :auto_complete, :project_id => 'ecookbook', :q => 'ReCiPe'
-    assert_response :success
-    assert_not_nil assigns(:issues)
-    assert assigns(:issues).detect {|issue| issue.subject.match /recipe/}
-  end
-  
-  def test_auto_complete_should_return_issue_with_given_id
-    get :auto_complete, :project_id => 'subproject1', :q => '13'
-    assert_response :success
-    assert_not_nil assigns(:issues)
-    assert assigns(:issues).include?(Issue.find(13))
-  end
-  
   def test_destroy_issue_with_no_time_entries
     assert_nil TimeEntry.find_by_issue_id(2)
     @request.session[:user_id] = 2
Index: trunk/test/integration/routing_test.rb
===================================================================
--- trunk/test/integration/routing_test.rb	(revision 3944)
+++ trunk/test/integration/routing_test.rb	(revision 3945)
@@ -100,7 +100,7 @@
     should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
     should_route :post, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
 
-    should_route :get, "/issues/auto_complete", :controller => 'issues', :action => 'auto_complete'
+    should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
   end
 
   context "issue categories" do
