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
e3f7cdda
Commit
e3f7cdda
authored
Mar 17, 2020
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Project.environments_for_scope to CE
Contributes to migration of Prometheus alerts to Core
parent
59b731a5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
24 deletions
+24
-24
app/models/project.rb
app/models/project.rb
+6
-0
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+0
-6
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+0
-18
spec/models/project_spec.rb
spec/models/project_spec.rb
+18
-0
No files found.
app/models/project.rb
View file @
e3f7cdda
...
...
@@ -2416,6 +2416,12 @@ class Project < ApplicationRecord
branch_protection
.
fully_protected?
||
branch_protection
.
developer_can_merge?
end
def
environments_for_scope
(
scope
)
quoted_scope
=
::
Gitlab
::
SQL
::
Glob
.
q
(
scope
)
environments
.
where
(
"name LIKE (
#{
::
Gitlab
::
SQL
::
Glob
.
to_like
(
quoted_scope
)
}
)"
)
# rubocop:disable GitlabSecurity/SqlInjection
end
private
def
closest_namespace_setting
(
name
)
...
...
ee/app/models/ee/project.rb
View file @
e3f7cdda
...
...
@@ -222,12 +222,6 @@ module EE
all_pipelines
.
newest_first
(
ref:
default_branch
).
with_reports
(
reports
).
take
end
def
environments_for_scope
(
scope
)
quoted_scope
=
::
Gitlab
::
SQL
::
Glob
.
q
(
scope
)
environments
.
where
(
"name LIKE (
#{
::
Gitlab
::
SQL
::
Glob
.
to_like
(
quoted_scope
)
}
)"
)
# rubocop:disable GitlabSecurity/SqlInjection
end
def
ensure_external_webhook_token
return
if
external_webhook_token
.
present?
...
...
ee/spec/models/project_spec.rb
View file @
e3f7cdda
...
...
@@ -433,24 +433,6 @@ describe Project do
end
end
describe
'#environments_for_scope'
do
let_it_be
(
:project
,
reload:
true
)
{
create
(
:project
)
}
before
do
create_list
(
:environment
,
2
,
project:
project
)
end
it
'retrieves all project environments when using the * wildcard'
do
expect
(
project
.
environments_for_scope
(
"*"
)).
to
eq
(
project
.
environments
)
end
it
'retrieves a specific project environment when using the name of that environment'
do
environment
=
project
.
environments
.
first
expect
(
project
.
environments_for_scope
(
environment
.
name
)).
to
eq
([
environment
])
end
end
describe
'#ensure_external_webhook_token'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
...
...
spec/models/project_spec.rb
View file @
e3f7cdda
...
...
@@ -5935,6 +5935,24 @@ describe Project do
end
end
describe
'#environments_for_scope'
do
let_it_be
(
:project
,
reload:
true
)
{
create
(
:project
)
}
before
do
create_list
(
:environment
,
2
,
project:
project
)
end
it
'retrieves all project environments when using the * wildcard'
do
expect
(
project
.
environments_for_scope
(
"*"
)).
to
eq
(
project
.
environments
)
end
it
'retrieves a specific project environment when using the name of that environment'
do
environment
=
project
.
environments
.
first
expect
(
project
.
environments_for_scope
(
environment
.
name
)).
to
eq
([
environment
])
end
end
def
finish_job
(
export_job
)
export_job
.
start
export_job
.
finish
...
...
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