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
1169d1e9
Commit
1169d1e9
authored
Jul 30, 2021
by
Luke Duncalfe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename .inherit and .not_inherited scopes
https://gitlab.com/gitlab-org/gitlab/-/issues/335355
parent
bcc330ff
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
10 deletions
+10
-10
app/controllers/admin/integrations_controller.rb
app/controllers/admin/integrations_controller.rb
+1
-1
app/models/integration.rb
app/models/integration.rb
+2
-2
app/services/groups/transfer_service.rb
app/services/groups/transfer_service.rb
+2
-2
app/services/projects/transfer_service.rb
app/services/projects/transfer_service.rb
+1
-1
spec/models/integration_spec.rb
spec/models/integration_spec.rb
+4
-4
No files found.
app/controllers/admin/integrations_controller.rb
View file @
1169d1e9
...
@@ -12,7 +12,7 @@ class Admin::IntegrationsController < Admin::ApplicationController
...
@@ -12,7 +12,7 @@ class Admin::IntegrationsController < Admin::ApplicationController
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
json
do
format
.
json
do
projects
=
Project
.
with_active_integration
(
integration
.
class
).
merge
(
::
Integration
.
not_inherited
)
projects
=
Project
.
with_active_integration
(
integration
.
class
).
merge
(
::
Integration
.
with_custom_settings
)
serializer
=
::
Integrations
::
ProjectSerializer
.
new
.
with_pagination
(
request
,
response
)
serializer
=
::
Integrations
::
ProjectSerializer
.
new
.
with_pagination
(
request
,
response
)
render
json:
serializer
.
represent
(
projects
)
render
json:
serializer
.
represent
(
projects
)
...
...
app/models/integration.rb
View file @
1169d1e9
...
@@ -77,8 +77,8 @@ class Integration < ApplicationRecord
...
@@ -77,8 +77,8 @@ class Integration < ApplicationRecord
scope
:by_type
,
->
(
type
)
{
where
(
type:
type
)
}
scope
:by_type
,
->
(
type
)
{
where
(
type:
type
)
}
scope
:by_active_flag
,
->
(
flag
)
{
where
(
active:
flag
)
}
scope
:by_active_flag
,
->
(
flag
)
{
where
(
active:
flag
)
}
scope
:inherit_from_id
,
->
(
id
)
{
where
(
inherit_from_id:
id
)
}
scope
:inherit_from_id
,
->
(
id
)
{
where
(
inherit_from_id:
id
)
}
scope
:
inherit
,
->
{
where
.
not
(
inherit_from_id:
nil
)
}
scope
:
with_default_settings
,
->
{
where
.
not
(
inherit_from_id:
nil
)
}
scope
:
not_inherited
,
->
{
where
(
inherit_from_id:
nil
)
}
scope
:
with_custom_settings
,
->
{
where
(
inherit_from_id:
nil
)
}
scope
:for_group
,
->
(
group
)
{
where
(
group_id:
group
,
type:
available_integration_types
(
include_project_specific:
false
))
}
scope
:for_group
,
->
(
group
)
{
where
(
group_id:
group
,
type:
available_integration_types
(
include_project_specific:
false
))
}
scope
:for_instance
,
->
{
where
(
instance:
true
,
type:
available_integration_types
(
include_project_specific:
false
))
}
scope
:for_instance
,
->
{
where
(
instance:
true
,
type:
available_integration_types
(
include_project_specific:
false
))
}
...
...
app/services/groups/transfer_service.rb
View file @
1169d1e9
...
@@ -208,12 +208,12 @@ module Groups
...
@@ -208,12 +208,12 @@ module Groups
end
end
def
update_integrations
def
update_integrations
@group
.
integrations
.
inherit
.
delete_all
@group
.
integrations
.
with_default_settings
.
delete_all
Integration
.
create_from_active_default_integrations
(
@group
,
:group_id
)
Integration
.
create_from_active_default_integrations
(
@group
,
:group_id
)
end
end
def
propagate_integrations
def
propagate_integrations
@group
.
integrations
.
inherit
.
each
do
|
integration
|
@group
.
integrations
.
with_default_settings
.
each
do
|
integration
|
PropagateIntegrationWorker
.
perform_async
(
integration
.
id
)
PropagateIntegrationWorker
.
perform_async
(
integration
.
id
)
end
end
end
end
...
...
app/services/projects/transfer_service.rb
View file @
1169d1e9
...
@@ -241,7 +241,7 @@ module Projects
...
@@ -241,7 +241,7 @@ module Projects
end
end
def
update_integrations
def
update_integrations
project
.
integrations
.
inherit
.
delete_all
project
.
integrations
.
with_default_settings
.
delete_all
Integration
.
create_from_active_default_integrations
(
project
,
:project_id
)
Integration
.
create_from_active_default_integrations
(
project
,
:project_id
)
end
end
end
end
...
...
spec/models/integration_spec.rb
View file @
1169d1e9
...
@@ -61,21 +61,21 @@ RSpec.describe Integration do
...
@@ -61,21 +61,21 @@ RSpec.describe Integration do
end
end
describe
'Scopes'
do
describe
'Scopes'
do
describe
'.
inherit
'
do
describe
'.
with_default_settings
'
do
it
'returns the correct integrations'
do
it
'returns the correct integrations'
do
instance_integration
=
create
(
:integration
,
:instance
)
instance_integration
=
create
(
:integration
,
:instance
)
inheriting_integration
=
create
(
:integration
,
inherit_from_id:
instance_integration
.
id
)
inheriting_integration
=
create
(
:integration
,
inherit_from_id:
instance_integration
.
id
)
expect
(
described_class
.
inherit
).
to
match_array
([
inheriting_integration
])
expect
(
described_class
.
with_default_settings
).
to
match_array
([
inheriting_integration
])
end
end
end
end
describe
'.
not_inherited
'
do
describe
'.
with_custom_settings
'
do
it
'returns the correct integrations'
do
it
'returns the correct integrations'
do
instance_integration
=
create
(
:integration
,
:instance
)
instance_integration
=
create
(
:integration
,
:instance
)
create
(
:integration
,
inherit_from_id:
instance_integration
.
id
)
create
(
:integration
,
inherit_from_id:
instance_integration
.
id
)
expect
(
described_class
.
not_inherited
).
to
match_array
([
instance_integration
])
expect
(
described_class
.
with_custom_settings
).
to
match_array
([
instance_integration
])
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