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
...
@@ -110,7 +110,7 @@ class Explore::ProjectsController < Explore::ApplicationController
end
end
def
load_topic
def
load_topic
@topic
=
Projects
::
Topic
.
find_by_name
(
params
[
:topic_name
])
@topic
=
Projects
::
Topic
.
find_by_name
_case_insensitive
(
params
[
:topic_name
])
end
end
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
...
...
app/models/projects/topic.rb
View file @
f55748d3
...
@@ -23,6 +23,10 @@ module Projects
...
@@ -23,6 +23,10 @@ module Projects
end
end
class
<<
self
class
<<
self
def
find_by_name_case_insensitive
(
name
)
find_by
(
'LOWER(name) = ?'
,
name
.
downcase
)
end
def
search
(
query
)
def
search
(
query
)
fuzzy_search
(
query
,
[
:name
])
fuzzy_search
(
query
,
[
:name
])
end
end
...
...
spec/controllers/explore/projects_controller_spec.rb
View file @
f55748d3
...
@@ -112,6 +112,13 @@ RSpec.describe Explore::ProjectsController do
...
@@ -112,6 +112,13 @@ RSpec.describe Explore::ProjectsController do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
'topic'
)
expect
(
response
).
to
render_template
(
'topic'
)
end
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
end
end
end
...
...
spec/models/projects/topic_spec.rb
View file @
f55748d3
...
@@ -56,6 +56,14 @@ RSpec.describe Projects::Topic do
...
@@ -56,6 +56,14 @@ RSpec.describe Projects::Topic do
end
end
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
describe
'#search'
do
it
'returns topics with a matching name'
do
it
'returns topics with a matching name'
do
expect
(
described_class
.
search
(
topic
.
name
)).
to
eq
([
topic
])
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