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
413455ca
Commit
413455ca
authored
Mar 23, 2020
by
Arturo Herrero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract shared examples for service templates
parent
7204ffea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
13 deletions
+11
-13
spec/models/service_spec.rb
spec/models/service_spec.rb
+11
-13
No files found.
spec/models/service_spec.rb
View file @
413455ca
...
@@ -152,14 +152,18 @@ describe Service do
...
@@ -152,14 +152,18 @@ describe Service do
describe
'template'
do
describe
'template'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
shared_examples
'retrieves service templates'
do
it
'returns the available service templates'
do
expect
(
Service
.
find_or_create_templates
.
pluck
(
:type
)).
to
match_array
(
Service
.
available_services_types
)
end
end
describe
'.find_or_create_templates'
do
describe
'.find_or_create_templates'
do
it
'creates service templates'
do
it
'creates service templates'
do
expect
{
Service
.
find_or_create_templates
}.
to
change
{
Service
.
count
}.
from
(
0
).
to
(
Service
.
available_services_names
.
size
)
expect
{
Service
.
find_or_create_templates
}.
to
change
{
Service
.
count
}.
from
(
0
).
to
(
Service
.
available_services_names
.
size
)
end
end
it
'returns the available service templates'
do
it_behaves_like
'retrieves service templates'
expect
(
Service
.
find_or_create_templates
.
map
(
&
:type
)).
to
match_array
(
Service
.
available_services_types
)
end
context
'with all existing templates'
do
context
'with all existing templates'
do
before
do
before
do
...
@@ -172,9 +176,7 @@ describe Service do
...
@@ -172,9 +176,7 @@ describe Service do
expect
{
Service
.
find_or_create_templates
}.
to
change
{
Service
.
count
}.
by
(
0
)
expect
{
Service
.
find_or_create_templates
}.
to
change
{
Service
.
count
}.
by
(
0
)
end
end
it
'returns the available service templates'
do
it_behaves_like
'retrieves service templates'
expect
(
Service
.
find_or_create_templates
.
map
(
&
:type
)).
to
match_array
(
Service
.
available_services_types
)
end
context
'with a previous existing service (Previous) and a new service (Asana)'
do
context
'with a previous existing service (Previous) and a new service (Asana)'
do
before
do
before
do
...
@@ -182,24 +184,20 @@ describe Service do
...
@@ -182,24 +184,20 @@ describe Service do
Service
.
delete_by
(
type:
'AsanaService'
,
template:
true
)
Service
.
delete_by
(
type:
'AsanaService'
,
template:
true
)
end
end
it
'returns the available service templates'
do
it_behaves_like
'retrieves service templates'
expect
(
Service
.
find_or_create_templates
.
map
(
&
:type
)).
to
match_array
(
Service
.
available_services_types
)
end
end
end
end
end
context
'with a few existing templates'
do
context
'with a few existing templates'
do
before
do
before
do
JiraService
.
create
(
template:
tru
e
)
create
(
:jira_service
,
:templat
e
)
end
end
it
'creates the rest of the service templates'
do
it
'creates the rest of the service templates'
do
expect
{
Service
.
find_or_create_templates
}.
to
change
{
Service
.
count
}.
from
(
1
).
to
(
Service
.
available_services_names
.
size
)
expect
{
Service
.
find_or_create_templates
}.
to
change
{
Service
.
count
}.
from
(
1
).
to
(
Service
.
available_services_names
.
size
)
end
end
it
'returns the available service templates'
do
it_behaves_like
'retrieves service templates'
expect
(
Service
.
find_or_create_templates
.
map
(
&
:type
)).
to
match_array
(
Service
.
available_services_types
)
end
end
end
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