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
ad7779cd
Commit
ad7779cd
authored
May 27, 2020
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add and use with_all_applications trait
DRY up a couple of places where we do so
parent
bedde99a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
35 deletions
+21
-35
spec/factories/clusters/clusters.rb
spec/factories/clusters/clusters.rb
+13
-0
spec/models/clusters/cluster_spec.rb
spec/models/clusters/cluster_spec.rb
+8
-35
No files found.
spec/factories/clusters/clusters.rb
View file @
ad7779cd
...
...
@@ -86,6 +86,19 @@ FactoryBot.define do
application_helm
factory:
%i(clusters_applications_helm installed)
end
trait
:with_all_applications
do
application_helm
factory:
%i(clusters_applications_helm installed)
application_ingress
factory:
%i(clusters_applications_ingress installed)
application_cert_manager
factory:
%i(clusters_applications_cert_manager installed)
application_crossplane
factory:
%i(clusters_applications_crossplane installed)
application_prometheus
factory:
%i(clusters_applications_prometheus installed)
application_runner
factory:
%i(clusters_applications_runner installed)
application_jupyter
factory:
%i(clusters_applications_jupyter installed)
application_knative
factory:
%i(clusters_applications_knative installed)
application_elastic_stack
factory:
%i(clusters_applications_elastic_stack installed)
application_fluentd
factory:
%i(clusters_applications_fluentd installed)
end
trait
:with_domain
do
domain
{
'example.com'
}
end
...
...
spec/models/clusters/cluster_spec.rb
View file @
ad7779cd
...
...
@@ -573,19 +573,12 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
end
context
'when applications are created'
do
let!
(
:helm
)
{
create
(
:clusters_applications_helm
,
cluster:
cluster
)
}
let!
(
:ingress
)
{
create
(
:clusters_applications_ingress
,
cluster:
cluster
)
}
let!
(
:cert_manager
)
{
create
(
:clusters_applications_cert_manager
,
cluster:
cluster
)
}
let!
(
:crossplane
)
{
create
(
:clusters_applications_crossplane
,
cluster:
cluster
)
}
let!
(
:prometheus
)
{
create
(
:clusters_applications_prometheus
,
cluster:
cluster
)
}
let!
(
:runner
)
{
create
(
:clusters_applications_runner
,
cluster:
cluster
)
}
let!
(
:jupyter
)
{
create
(
:clusters_applications_jupyter
,
cluster:
cluster
)
}
let!
(
:knative
)
{
create
(
:clusters_applications_knative
,
cluster:
cluster
)
}
let!
(
:elastic_stack
)
{
create
(
:clusters_applications_elastic_stack
,
cluster:
cluster
)
}
let!
(
:fluentd
)
{
create
(
:clusters_applications_fluentd
,
cluster:
cluster
)
}
let
(
:cluster
)
{
create
(
:cluster
,
:with_all_applications
)
}
it
'returns a list of created applications'
do
is_expected
.
to
contain_exactly
(
helm
,
ingress
,
cert_manager
,
crossplane
,
prometheus
,
runner
,
jupyter
,
knative
,
elastic_stack
,
fluentd
)
it
'returns a list of created applications'
,
:aggregate_failures
do
is_expected
.
to
have_attributes
(
size:
described_class
::
APPLICATIONS
.
size
)
is_expected
.
to
all
(
be_kind_of
(
::
Clusters
::
Concerns
::
ApplicationCore
))
is_expected
.
to
all
(
be_persisted
)
end
end
end
...
...
@@ -611,33 +604,13 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
end
context
'when application is persisted'
do
let!
(
:helm
)
{
create
(
:clusters_applications_helm
,
cluster:
cluster
)
}
let!
(
:ingress
)
{
create
(
:clusters_applications_ingress
,
cluster:
cluster
)
}
let!
(
:cert_manager
)
{
create
(
:clusters_applications_cert_manager
,
cluster:
cluster
)
}
let!
(
:crossplane
)
{
create
(
:clusters_applications_crossplane
,
cluster:
cluster
)
}
let!
(
:prometheus
)
{
create
(
:clusters_applications_prometheus
,
cluster:
cluster
)
}
let!
(
:runner
)
{
create
(
:clusters_applications_runner
,
cluster:
cluster
)
}
let!
(
:jupyter
)
{
create
(
:clusters_applications_jupyter
,
cluster:
cluster
)
}
let!
(
:knative
)
{
create
(
:clusters_applications_knative
,
cluster:
cluster
)
}
let!
(
:elastic_stack
)
{
create
(
:clusters_applications_elastic_stack
,
cluster:
cluster
)
}
let!
(
:fluentd
)
{
create
(
:clusters_applications_fluentd
,
cluster:
cluster
)
}
let
(
:cluster
)
{
create
(
:cluster
,
:with_all_applications
)
}
it
'returns the persisted application'
,
:aggregate_failures
do
{
Clusters
::
Applications
::
Helm
=>
helm
,
Clusters
::
Applications
::
Ingress
=>
ingress
,
Clusters
::
Applications
::
CertManager
=>
cert_manager
,
Clusters
::
Applications
::
Crossplane
=>
crossplane
,
Clusters
::
Applications
::
Prometheus
=>
prometheus
,
Clusters
::
Applications
::
Runner
=>
runner
,
Clusters
::
Applications
::
Jupyter
=>
jupyter
,
Clusters
::
Applications
::
Knative
=>
knative
,
Clusters
::
Applications
::
ElasticStack
=>
elastic_stack
,
Clusters
::
Applications
::
Fluentd
=>
fluentd
}.
each
do
|
application_class
,
expected_object
|
described_class
::
APPLICATIONS
.
each_value
do
|
application_class
|
application
=
cluster
.
find_or_build_application
(
application_class
)
expect
(
application
).
to
eq
(
expected_object
)
expect
(
application
).
to
be_kind_of
(
::
Clusters
::
Concerns
::
ApplicationCore
)
expect
(
application
).
to
be_persisted
end
end
...
...
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