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
6cfeab55
Commit
6cfeab55
authored
Oct 13, 2020
by
Arturo Herrero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for create from default integration
parent
a38a5a14
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
0 deletions
+98
-0
spec/models/service_spec.rb
spec/models/service_spec.rb
+98
-0
No files found.
spec/models/service_spec.rb
View file @
6cfeab55
...
...
@@ -501,6 +501,104 @@ RSpec.describe Service do
end
end
describe
'.create_from_active_default_integrations'
do
context
'with an active service template'
do
let_it_be
(
:template_integration
)
{
create
(
:prometheus_service
,
:template
,
api_url:
'https://prometheus.template.com/'
)
}
it
'creates a service from the template'
do
described_class
.
create_from_active_default_integrations
(
project
,
:project_id
,
with_templates:
true
)
expect
(
project
.
reload
.
services
.
size
).
to
eq
(
1
)
expect
(
project
.
reload
.
services
.
first
.
api_url
).
to
eq
(
template_integration
.
api_url
)
expect
(
project
.
reload
.
services
.
first
.
inherit_from_id
).
to
be_nil
end
context
'with an active instance-level integration'
do
let!
(
:instance_integration
)
{
create
(
:prometheus_service
,
:instance
,
api_url:
'https://prometheus.instance.com/'
)
}
it
'creates a service from the instance-level integration'
do
described_class
.
create_from_active_default_integrations
(
project
,
:project_id
,
with_templates:
true
)
expect
(
project
.
reload
.
services
.
size
).
to
eq
(
1
)
expect
(
project
.
reload
.
services
.
first
.
api_url
).
to
eq
(
instance_integration
.
api_url
)
expect
(
project
.
reload
.
services
.
first
.
inherit_from_id
).
to
eq
(
instance_integration
.
id
)
end
context
'passing a group'
do
it
'creates a service from the instance-level integration'
do
described_class
.
create_from_active_default_integrations
(
group
,
:group_id
)
expect
(
group
.
reload
.
services
.
size
).
to
eq
(
1
)
expect
(
group
.
reload
.
services
.
first
.
api_url
).
to
eq
(
instance_integration
.
api_url
)
expect
(
group
.
reload
.
services
.
first
.
inherit_from_id
).
to
eq
(
instance_integration
.
id
)
end
end
context
'with an active group-level integration'
do
let!
(
:group_integration
)
{
create
(
:prometheus_service
,
group:
group
,
project:
nil
,
api_url:
'https://prometheus.group.com/'
)
}
it
'creates a service from the group-level integration'
do
described_class
.
create_from_active_default_integrations
(
project
,
:project_id
,
with_templates:
true
)
expect
(
project
.
reload
.
services
.
size
).
to
eq
(
1
)
expect
(
project
.
reload
.
services
.
first
.
api_url
).
to
eq
(
group_integration
.
api_url
)
expect
(
project
.
reload
.
services
.
first
.
inherit_from_id
).
to
eq
(
group_integration
.
id
)
end
context
'passing a group'
do
let!
(
:subgroup
)
{
create
(
:group
,
parent:
group
)
}
it
'creates a service from the group-level integration'
do
described_class
.
create_from_active_default_integrations
(
subgroup
,
:group_id
)
expect
(
subgroup
.
reload
.
services
.
size
).
to
eq
(
1
)
expect
(
subgroup
.
reload
.
services
.
first
.
api_url
).
to
eq
(
group_integration
.
api_url
)
expect
(
subgroup
.
reload
.
services
.
first
.
inherit_from_id
).
to
eq
(
group_integration
.
id
)
end
end
context
'with an active subgroup'
do
let!
(
:subgroup_integration
)
{
create
(
:prometheus_service
,
group:
subgroup
,
project:
nil
,
api_url:
'https://prometheus.subgroup.com/'
)
}
let!
(
:subgroup
)
{
create
(
:group
,
parent:
group
)
}
let
(
:project
)
{
create
(
:project
,
group:
subgroup
)
}
it
'creates a service from the subgroup-level integration'
do
described_class
.
create_from_active_default_integrations
(
project
,
:project_id
,
with_templates:
true
)
expect
(
project
.
reload
.
services
.
size
).
to
eq
(
1
)
expect
(
project
.
reload
.
services
.
first
.
api_url
).
to
eq
(
subgroup_integration
.
api_url
)
expect
(
project
.
reload
.
services
.
first
.
inherit_from_id
).
to
eq
(
subgroup_integration
.
id
)
end
context
'passing a group'
do
let!
(
:sub_subgroup
)
{
create
(
:group
,
parent:
subgroup
)
}
it
'creates a service from the subgroup-level integration'
do
described_class
.
create_from_active_default_integrations
(
sub_subgroup
,
:group_id
)
expect
(
sub_subgroup
.
reload
.
services
.
size
).
to
eq
(
1
)
expect
(
sub_subgroup
.
reload
.
services
.
first
.
api_url
).
to
eq
(
subgroup_integration
.
api_url
)
expect
(
sub_subgroup
.
reload
.
services
.
first
.
inherit_from_id
).
to
eq
(
subgroup_integration
.
id
)
end
context
'having a service inheriting settings'
do
let!
(
:subgroup_integration
)
{
create
(
:prometheus_service
,
group:
subgroup
,
project:
nil
,
inherit_from_id:
group_integration
.
id
,
api_url:
'https://prometheus.subgroup.com/'
)
}
it
'creates a service from the group-level integration'
do
described_class
.
create_from_active_default_integrations
(
sub_subgroup
,
:group_id
)
expect
(
sub_subgroup
.
reload
.
services
.
size
).
to
eq
(
1
)
expect
(
sub_subgroup
.
reload
.
services
.
first
.
api_url
).
to
eq
(
group_integration
.
api_url
)
expect
(
sub_subgroup
.
reload
.
services
.
first
.
inherit_from_id
).
to
eq
(
group_integration
.
id
)
end
end
end
end
end
end
end
end
describe
"{property}_changed?"
do
let
(
:service
)
do
BambooService
.
create
(
...
...
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