Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f55748d3
Commit
f55748d3
authored
Apr 08, 2022
by
Jonas Wälter
Committed by
Jan Provaznik
Apr 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Find topic by case insensitive name for detail page
Changelog: changed
parent
5e170ccc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
1 deletion
+20
-1
app/controllers/explore/projects_controller.rb
app/controllers/explore/projects_controller.rb
+1
-1
app/models/projects/topic.rb
app/models/projects/topic.rb
+4
-0
spec/controllers/explore/projects_controller_spec.rb
spec/controllers/explore/projects_controller_spec.rb
+7
-0
spec/models/projects/topic_spec.rb
spec/models/projects/topic_spec.rb
+8
-0
No files found.
app/controllers/explore/projects_controller.rb
View file @
f55748d3
...
...
@@ -110,7 +110,7 @@ class Explore::ProjectsController < Explore::ApplicationController
end
def
load_topic
@topic
=
Projects
::
Topic
.
find_by_name
(
params
[
:topic_name
])
@topic
=
Projects
::
Topic
.
find_by_name
_case_insensitive
(
params
[
:topic_name
])
end
# rubocop: disable CodeReuse/ActiveRecord
...
...
app/models/projects/topic.rb
View file @
f55748d3
...
...
@@ -23,6 +23,10 @@ module Projects
end
class
<<
self
def
find_by_name_case_insensitive
(
name
)
find_by
(
'LOWER(name) = ?'
,
name
.
downcase
)
end
def
search
(
query
)
fuzzy_search
(
query
,
[
:name
])
end
...
...
spec/controllers/explore/projects_controller_spec.rb
View file @
f55748d3
...
...
@@ -112,6 +112,13 @@ RSpec.describe Explore::ProjectsController do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
'topic'
)
end
it
'finds topic by case insensitive name'
do
get
:topic
,
params:
{
topic_name:
'TOPIC1'
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
'topic'
)
end
end
end
end
...
...
spec/models/projects/topic_spec.rb
View file @
f55748d3
...
...
@@ -56,6 +56,14 @@ RSpec.describe Projects::Topic do
end
end
describe
'#find_by_name_case_insensitive'
do
it
'returns topic with case insensitive name'
do
%w(topic TOPIC Topic)
.
each
do
|
name
|
expect
(
described_class
.
find_by_name_case_insensitive
(
name
)).
to
eq
(
topic
)
end
end
end
describe
'#search'
do
it
'returns topics with a matching name'
do
expect
(
described_class
.
search
(
topic
.
name
)).
to
eq
([
topic
])
...
...
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