Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
40dbfd77
Commit
40dbfd77
authored
Mar 14, 2011
by
Felix Schäfer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'edavis10_280-issue-autocomplete-match-issue-ids'
parents
cdb80f69
7415dcb6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
auto_completes_controller.rb
app/controllers/auto_completes_controller.rb
+4
-1
auto_completes_controller_test.rb
test/functional/auto_completes_controller_test.rb
+18
-0
No files found.
app/controllers/auto_completes_controller.rb
View file @
40dbfd77
...
@@ -9,7 +9,10 @@ class AutoCompletesController < ApplicationController
...
@@ -9,7 +9,10 @@ class AutoCompletesController < ApplicationController
@issues
<<
query
.
visible
.
find_by_id
(
q
.
to_i
)
@issues
<<
query
.
visible
.
find_by_id
(
q
.
to_i
)
end
end
unless
q
.
blank?
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
end
@issues
.
compact!
@issues
.
compact!
render
:layout
=>
false
render
:layout
=>
false
...
...
test/functional/auto_completes_controller_test.rb
View file @
40dbfd77
...
@@ -16,6 +16,24 @@ class AutoCompletesControllerTest < ActionController::TestCase
...
@@ -16,6 +16,24 @@ class AutoCompletesControllerTest < ActionController::TestCase
assert_not_nil
assigns
(
:issues
)
assert_not_nil
assigns
(
:issues
)
assert
assigns
(
:issues
).
include?
(
Issue
.
find
(
13
))
assert
assigns
(
:issues
).
include?
(
Issue
.
find
(
13
))
end
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
def
test_auto_complete_with_scope_all_and_cross_project_relations
Setting
.
cross_project_issue_relations
=
'1'
Setting
.
cross_project_issue_relations
=
'1'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment