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
220112d3
Commit
220112d3
authored
Oct 30, 2020
by
Arturo Herrero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve specs having subqueries
parent
32d9cf69
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
22 deletions
+44
-22
spec/services/bulk_create_integration_service_spec.rb
spec/services/bulk_create_integration_service_spec.rb
+44
-22
No files found.
spec/services/bulk_create_integration_service_spec.rb
View file @
220112d3
...
...
@@ -5,12 +5,14 @@ require 'spec_helper'
RSpec
.
describe
BulkCreateIntegrationService
do
include
JiraServiceHelper
before
do
before
_all
do
stub_jira_service_test
end
let_it_be
(
:instance_integration
)
{
create
(
:jira_service
,
:instance
)
}
let_it_be
(
:template_integration
)
{
create
(
:jira_service
,
:template
)
}
let_it_be
(
:excluded_group
)
{
create
(
:group
)
}
let_it_be
(
:excluded_project
)
{
create
(
:project
,
group:
excluded_group
)
}
let
(
:instance_integration
)
{
create
(
:jira_service
,
:instance
)
}
let
(
:template_integration
)
{
create
(
:jira_service
,
:template
)
}
let
(
:excluded_attributes
)
{
%w[id project_id group_id inherit_from_id instance template created_at updated_at]
}
shared_examples
'creates integration from batch ids'
do
...
...
@@ -46,15 +48,19 @@ RSpec.describe BulkCreateIntegrationService do
described_class
.
new
(
integration
,
batch
,
association
).
execute
expect
(
project
.
reload
.
has_external_issue_tracker
).
to
eq
(
true
)
expect
(
excluded_project
.
reload
.
has_external_issue_tracker
).
to
eq
(
false
)
end
context
'with an external wiki integration'
do
let
(
:integration
)
{
create
(
:external_wiki_service
,
:instance
)
}
before
do
integration
.
update!
(
category:
'common'
,
type:
'ExternalWikiService'
)
end
it
'updates projects#has_external_wiki for external wiki services'
do
described_class
.
new
(
integration
,
batch
,
association
).
execute
expect
(
project
.
reload
.
has_external_wiki
).
to
eq
(
true
)
expect
(
excluded_project
.
reload
.
has_external_wiki
).
to
eq
(
false
)
end
end
end
...
...
@@ -77,14 +83,14 @@ RSpec.describe BulkCreateIntegrationService do
end
end
context
'
with
an instance-level integration'
do
context
'
passing
an instance-level integration'
do
let
(
:integration
)
{
instance_integration
}
let
(
:inherit_from_id
)
{
integration
.
id
}
context
'with a project association'
do
let!
(
:project
)
{
create
(
:project
)
}
let
(
:created_integration
)
{
project
.
jira_service
}
let
(
:batch
)
{
Project
.
w
ithout_integration
(
integration
)
}
let
(
:batch
)
{
Project
.
w
here
(
id:
project
.
id
)
}
let
(
:association
)
{
'project'
}
it_behaves_like
'creates integration from batch ids'
...
...
@@ -101,36 +107,52 @@ RSpec.describe BulkCreateIntegrationService do
end
context
'with a group association'
do
let
_it_be
(
:group
)
{
create
(
:group
)
}
let
!
(
:group
)
{
create
(
:group
)
}
let
(
:created_integration
)
{
Service
.
find_by
(
group:
group
)
}
let
(
:batch
)
{
Group
.
all
}
let
(
:batch
)
{
Group
.
where
(
id:
group
.
id
)
}
let
(
:association
)
{
'group'
}
it_behaves_like
'creates integration from batch ids'
it_behaves_like
'updates inherit_from_id'
end
end
context
'with a subgroup association'
do
let_it_be
(
:group_integration
)
{
create
(
:jira_service
,
group:
group
,
project:
nil
,
inherit_from_id:
instance_integration
.
id
)
}
let_it_be
(
:subgroup
)
{
create
(
:group
,
parent:
group
)
}
let
(
:integration
)
{
group_integration
}
let
(
:created_integration
)
{
Service
.
find_by
(
group:
subgroup
)
}
let
(
:batch
)
{
Group
.
all
}
let
(
:association
)
{
'group'
}
let
(
:inherit_from_id
)
{
instance_integration
.
id
}
it_behaves_like
'creates integration from batch ids'
it_behaves_like
'updates inherit_from_id'
end
context
'passing a group integration'
do
let_it_be
(
:group
)
{
create
(
:group
)
}
context
'with a project association'
do
let!
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:integration
)
{
create
(
:jira_service
,
group:
group
,
project:
nil
)
}
let
(
:created_integration
)
{
project
.
jira_service
}
let
(
:batch
)
{
Project
.
where
(
id:
Project
.
minimum
(
:id
)
..
Project
.
maximum
(
:id
)).
without_integration
(
integration
).
in_namespace
(
integration
.
group
.
self_and_descendants
)
}
let
(
:association
)
{
'project'
}
let
(
:inherit_from_id
)
{
integration
.
id
}
it_behaves_like
'creates integration from batch ids'
it_behaves_like
'updates inherit_from_id'
it_behaves_like
'updates project callbacks'
end
context
'with a group association'
do
let!
(
:subgroup
)
{
create
(
:group
,
parent:
group
)
}
let
(
:integration
)
{
create
(
:jira_service
,
group:
group
,
project:
nil
,
inherit_from_id:
instance_integration
.
id
)
}
let
(
:created_integration
)
{
Service
.
find_by
(
group:
subgroup
)
}
let
(
:batch
)
{
Group
.
where
(
id:
subgroup
.
id
)
}
let
(
:association
)
{
'group'
}
let
(
:inherit_from_id
)
{
instance_integration
.
id
}
it_behaves_like
'creates integration from batch ids'
it_behaves_like
'updates inherit_from_id'
end
end
context
'
with
a template integration'
do
context
'
passing
a template integration'
do
let
(
:integration
)
{
template_integration
}
context
'with a project association'
do
let!
(
:project
)
{
create
(
:project
)
}
let
(
:created_integration
)
{
project
.
jira_service
}
let
(
:batch
)
{
Project
.
all
}
let
(
:batch
)
{
Project
.
where
(
id:
project
.
id
)
}
let
(
:association
)
{
'project'
}
let
(
:inherit_from_id
)
{
integration
.
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