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
9783ae9a
Commit
9783ae9a
authored
Jun 06, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add with_deployment_in_environment to Cluster
parent
c2f58421
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
app/models/clusters/cluster.rb
app/models/clusters/cluster.rb
+1
-0
spec/models/clusters/cluster_spec.rb
spec/models/clusters/cluster_spec.rb
+18
-0
No files found.
app/models/clusters/cluster.rb
View file @
9783ae9a
...
...
@@ -136,6 +136,7 @@ module Clusters
conditions
=
{
projects:
{
alerts_service:
[
:data
]
}
}
includes
(
conditions
).
joins
(
conditions
).
where
(
projects:
{
id:
project_ids
})
end
scope
:with_deployment_in_environment
,
->
(
environment
)
{
joins
(
:deployments
).
merge
(
Deployment
.
for_environment
(
environment
))
}
def
self
.
ancestor_clusters_for_clusterable
(
clusterable
,
hierarchy_order: :asc
)
return
[]
if
clusterable
.
is_a?
(
Instance
)
...
...
spec/models/clusters/cluster_spec.rb
View file @
9783ae9a
...
...
@@ -207,6 +207,24 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
end
end
describe
'.with_project_alert_service_data'
do
subject
{
described_class
.
with_deployment_in_environment
(
environment
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let!
(
:cluster
)
{
create
(
:cluster
,
projects:
[
project
])
}
let!
(
:environment
)
{
create
(
:environment
)
}
context
'deployment in environment'
do
let!
(
:deployment
)
{
create
(
:deployment
,
cluster:
cluster
,
environment:
environment
,
sha:
cluster
.
project
.
commit
.
id
)
}
it
{
is_expected
.
to
include
(
cluster
)
}
end
context
'no deployment in environment'
do
it
{
is_expected
.
not_to
include
(
cluster
)
}
end
end
describe
'.for_project_namespace'
do
subject
{
described_class
.
for_project_namespace
(
namespace_id
)
}
...
...
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