[#280] Include matching issue ids in the auto_completer.
Using SQL CAST() to convert the issue ids to strings so LIKE will work properly.
This commit is contained in:
parent
85e1333e0c
commit
ae0851ddb4
|
@ -9,7 +9,10 @@ class AutoCompletesController < ApplicationController
|
|||
@issues << query.visible.find_by_id(q.to_i)
|
||||
end
|
||||
unless q.blank?
|
||||
@issues += query.visible.find(:all, :conditions => ["LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%"], :limit => 10)
|
||||
@issues += query.visible.find(:all,
|
||||
:limit => 10,
|
||||
:order => "#{Issue.table_name}.id ASC",
|
||||
:conditions => ["LOWER(#{Issue.table_name}.subject) LIKE :q OR CAST(#{Issue.table_name}.id AS CHAR(13)) LIKE :q", {:q => "%#{q.downcase}%" }])
|
||||
end
|
||||
@issues.compact!
|
||||
render :layout => false
|
||||
|
|
|
@ -16,6 +16,24 @@ class AutoCompletesControllerTest < ActionController::TestCase
|
|||
assert_not_nil assigns(:issues)
|
||||
assert assigns(:issues).include?(Issue.find(13))
|
||||
end
|
||||
|
||||
test 'should return issues matching a given id' do
|
||||
@project = Project.find('subproject1')
|
||||
@issue_21 = Issue.generate_for_project!(@project, :id => 21)
|
||||
@issue_101 = Issue.generate_for_project!(@project, :id => 101)
|
||||
@issue_102 = Issue.generate_for_project!(@project, :id => 102)
|
||||
@issue_with_subject = Issue.generate_for_project!(@project, :subject => 'This has 1 in the subject')
|
||||
|
||||
get :issues, :project_id => @project.id, :q => '1'
|
||||
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:issues)
|
||||
assert assigns(:issues).include?(Issue.find(13))
|
||||
assert assigns(:issues).include?(@issue_21)
|
||||
assert assigns(:issues).include?(@issue_101)
|
||||
assert assigns(:issues).include?(@issue_102)
|
||||
assert assigns(:issues).include?(@issue_with_subject)
|
||||
end
|
||||
|
||||
def test_auto_complete_with_scope_all_and_cross_project_relations
|
||||
Setting.cross_project_issue_relations = '1'
|
||||
|
|
Loading…
Reference in New Issue