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
a4f87c71
Commit
a4f87c71
authored
Sep 17, 2019
by
Jason Goodman
Committed by
Thong Kuah
Sep 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Match Environment Spec Search Case Insensitively
parent
f1883d40
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
1 deletion
+16
-1
app/models/environment.rb
app/models/environment.rb
+1
-1
ee/changelogs/unreleased/case-insensitive-env-search.yml
ee/changelogs/unreleased/case-insensitive-env-search.yml
+5
-0
spec/controllers/projects/environments_controller_spec.rb
spec/controllers/projects/environments_controller_spec.rb
+10
-0
No files found.
app/models/environment.rb
View file @
a4f87c71
...
@@ -54,7 +54,7 @@ class Environment < ApplicationRecord
...
@@ -54,7 +54,7 @@ class Environment < ApplicationRecord
# Search environments which have names like the given query.
# Search environments which have names like the given query.
# Do not set a large limit unless you've confirmed that it works on gitlab.com scale.
# Do not set a large limit unless you've confirmed that it works on gitlab.com scale.
scope
:for_name_like
,
->
(
query
,
limit:
5
)
do
scope
:for_name_like
,
->
(
query
,
limit:
5
)
do
where
(
'name LIKE ?'
,
"
#{
sanitize_sql_like
(
query
)
}
%"
).
limit
(
limit
)
where
(
arel_table
[
:name
].
matches
(
"
#{
sanitize_sql_like
query
}
%"
)
).
limit
(
limit
)
end
end
scope
:for_project
,
->
(
project
)
{
where
(
project_id:
project
)
}
scope
:for_project
,
->
(
project
)
{
where
(
project_id:
project
)
}
...
...
ee/changelogs/unreleased/case-insensitive-env-search.yml
0 → 100644
View file @
a4f87c71
---
title
:
Match environment names case insensitively for feature flag spec search
merge_request
:
16691
author
:
type
:
fixed
spec/controllers/projects/environments_controller_spec.rb
View file @
a4f87c71
...
@@ -701,6 +701,16 @@ describe Projects::EnvironmentsController do
...
@@ -701,6 +701,16 @@ describe Projects::EnvironmentsController do
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
end
end
context
'when query matches case insensitively'
do
let
(
:query
)
{
'Prod'
}
it
'returns matched results'
do
get
:search
,
params:
environment_params
(
format: :json
,
query:
query
)
expect
(
json_response
).
to
contain_exactly
(
'production'
)
end
end
end
end
def
environment_params
(
opts
=
{})
def
environment_params
(
opts
=
{})
...
...
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