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
b8c957ad
Commit
b8c957ad
authored
Jun 21, 2021
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename available integration type listing method
Renames available_services_names to available_integration_types
parent
a4d50620
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
21 deletions
+21
-21
app/graphql/types/projects/service_type_enum.rb
app/graphql/types/projects/service_type_enum.rb
+1
-1
app/models/integration.rb
app/models/integration.rb
+8
-8
spec/graphql/types/projects/services_enum_spec.rb
spec/graphql/types/projects/services_enum_spec.rb
+1
-1
spec/models/integration_spec.rb
spec/models/integration_spec.rb
+11
-11
No files found.
app/graphql/types/projects/service_type_enum.rb
View file @
b8c957ad
...
...
@@ -5,7 +5,7 @@ module Types
class
ServiceTypeEnum
<
BaseEnum
graphql_name
'ServiceType'
::
Integration
.
available_
services
_types
(
include_dev:
false
).
each
do
|
type
|
::
Integration
.
available_
integration
_types
(
include_dev:
false
).
each
do
|
type
|
value
type
.
underscore
.
upcase
,
value:
type
,
description:
"
#{
type
}
type"
end
end
...
...
app/models/integration.rb
View file @
b8c957ad
...
...
@@ -108,9 +108,9 @@ class Integration < ApplicationRecord
scope
:by_active_flag
,
->
(
flag
)
{
where
(
active:
flag
)
}
scope
:inherit_from_id
,
->
(
id
)
{
where
(
inherit_from_id:
id
)
}
scope
:inherit
,
->
{
where
.
not
(
inherit_from_id:
nil
)
}
scope
:for_group
,
->
(
group
)
{
where
(
group_id:
group
,
type:
available_
services
_types
(
include_project_specific:
false
))
}
scope
:for_template
,
->
{
where
(
template:
true
,
type:
available_
services
_types
(
include_project_specific:
false
))
}
scope
:for_instance
,
->
{
where
(
instance:
true
,
type:
available_
services
_types
(
include_project_specific:
false
))
}
scope
:for_group
,
->
(
group
)
{
where
(
group_id:
group
,
type:
available_
integration
_types
(
include_project_specific:
false
))
}
scope
:for_template
,
->
{
where
(
template:
true
,
type:
available_
integration
_types
(
include_project_specific:
false
))
}
scope
:for_instance
,
->
{
where
(
instance:
true
,
type:
available_
integration
_types
(
include_project_specific:
false
))
}
scope
:push_hooks
,
->
{
where
(
push_events:
true
,
active:
true
)
}
scope
:tag_push_hooks
,
->
{
where
(
tag_push_events:
true
,
active:
true
)
}
...
...
@@ -238,7 +238,7 @@ class Integration < ApplicationRecord
def
self
.
nonexistent_services_types_for
(
scope
)
# Using #map instead of #pluck to save one query count. This is because
# ActiveRecord loaded the object here, so we don't need to query again later.
available_
services
_types
(
include_project_specific:
false
)
-
scope
.
map
(
&
:type
)
available_
integration
_types
(
include_project_specific:
false
)
-
scope
.
map
(
&
:type
)
end
private_class_method
:nonexistent_services_types_for
...
...
@@ -271,11 +271,11 @@ class Integration < ApplicationRecord
PROJECT_SPECIFIC_INTEGRATION_NAMES
end
# Returns a list of available
service
types.
# Returns a list of available
integration
types.
# Example: ["AsanaService", ...]
def
self
.
available_
services
_types
(
include_project_specific:
true
,
include_dev:
true
)
available_integration_names
(
include_project_specific:
include_project_specific
,
include_dev:
include_dev
).
map
do
|
service_name
|
integration_name_to_type
(
service_name
)
def
self
.
available_
integration
_types
(
include_project_specific:
true
,
include_dev:
true
)
available_integration_names
(
include_project_specific:
include_project_specific
,
include_dev:
include_dev
).
map
do
integration_name_to_type
(
_1
)
end
end
...
...
spec/graphql/types/projects/services_enum_spec.rb
View file @
b8c957ad
...
...
@@ -8,6 +8,6 @@ RSpec.describe GitlabSchema.types['ServiceType'] do
end
def
available_services_enum
::
Integration
.
available_
services
_types
(
include_dev:
false
).
map
(
&
:underscore
).
map
(
&
:upcase
)
::
Integration
.
available_
integration
_types
(
include_dev:
false
).
map
(
&
:underscore
).
map
(
&
:upcase
)
end
end
spec/models/integration_spec.rb
View file @
b8c957ad
...
...
@@ -140,10 +140,10 @@ RSpec.describe Integration do
end
describe
"Test Button"
do
let
(
:
service
)
{
build
(
:service
,
project:
project
)
}
let
(
:
integration
)
{
build
(
:service
,
project:
project
)
}
describe
'#can_test?'
do
subject
{
service
.
can_test?
}
subject
{
integration
.
can_test?
}
context
'when repository is not empty'
do
let
(
:project
)
{
build
(
:project
,
:repository
)
}
...
...
@@ -158,9 +158,9 @@ RSpec.describe Integration do
end
context
'when instance-level service'
do
Integration
.
available_
services_types
.
each
do
|
service_
type
|
let
(
:
service
)
do
described_class
.
send
(
:integration_type_to_model
,
service_
type
).
new
(
instance:
true
)
Integration
.
available_
integration_types
.
each
do
|
type
|
let
(
:
integration
)
do
described_class
.
send
(
:integration_type_to_model
,
type
).
new
(
instance:
true
)
end
it
{
is_expected
.
to
be_falsey
}
...
...
@@ -168,9 +168,9 @@ RSpec.describe Integration do
end
context
'when group-level service'
do
Integration
.
available_
services_types
.
each
do
|
service_
type
|
let
(
:
service
)
do
described_class
.
send
(
:integration_type_to_model
,
service_
type
).
new
(
group_id:
group
.
id
)
Integration
.
available_
integration_types
.
each
do
|
type
|
let
(
:
integration
)
do
described_class
.
send
(
:integration_type_to_model
,
type
).
new
(
group_id:
group
.
id
)
end
it
{
is_expected
.
to
be_falsey
}
...
...
@@ -266,7 +266,7 @@ RSpec.describe Integration do
context
'with all existing instances'
do
before
do
Integration
.
insert_all
(
Integration
.
available_
services
_types
(
include_project_specific:
false
).
map
{
|
type
|
{
instance:
true
,
type:
type
}
}
Integration
.
available_
integration
_types
(
include_project_specific:
false
).
map
{
|
type
|
{
instance:
true
,
type:
type
}
}
)
end
...
...
@@ -294,7 +294,7 @@ RSpec.describe Integration do
describe
'template'
do
shared_examples
'retrieves service templates'
do
it
'returns the available service templates'
do
expect
(
Integration
.
find_or_create_templates
.
pluck
(
:type
)).
to
match_array
(
Integration
.
available_
services
_types
(
include_project_specific:
false
))
expect
(
Integration
.
find_or_create_templates
.
pluck
(
:type
)).
to
match_array
(
Integration
.
available_
integration
_types
(
include_project_specific:
false
))
end
end
...
...
@@ -310,7 +310,7 @@ RSpec.describe Integration do
context
'with all existing templates'
do
before
do
Integration
.
insert_all
(
Integration
.
available_
services
_types
(
include_project_specific:
false
).
map
{
|
type
|
{
template:
true
,
type:
type
}
}
Integration
.
available_
integration
_types
(
include_project_specific:
false
).
map
{
|
type
|
{
template:
true
,
type:
type
}
}
)
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