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
cb38e99d
Commit
cb38e99d
authored
Aug 26, 2020
by
Arturo Herrero
Committed by
Kamil Trzciński
Aug 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename service model scopes
parent
e6184680
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
15 deletions
+15
-15
app/controllers/admin/application_settings_controller.rb
app/controllers/admin/application_settings_controller.rb
+1
-1
app/controllers/admin/services_controller.rb
app/controllers/admin/services_controller.rb
+1
-1
app/controllers/groups/settings/integrations_controller.rb
app/controllers/groups/settings/integrations_controller.rb
+1
-1
app/models/project.rb
app/models/project.rb
+2
-2
app/models/service.rb
app/models/service.rb
+5
-5
spec/features/admin/services/admin_visits_service_templates_spec.rb
...res/admin/services/admin_visits_service_templates_spec.rb
+1
-1
spec/models/service_spec.rb
spec/models/service_spec.rb
+4
-4
No files found.
app/controllers/admin/application_settings_controller.rb
View file @
cb38e99d
...
@@ -32,7 +32,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
...
@@ -32,7 +32,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end
end
def
integrations
def
integrations
@integrations
=
Service
.
find_or_initialize_all
(
Service
.
instances
).
sort_by
(
&
:title
)
@integrations
=
Service
.
find_or_initialize_all
(
Service
.
for_instance
).
sort_by
(
&
:title
)
end
end
def
update
def
update
...
...
app/controllers/admin/services_controller.rb
View file @
cb38e99d
...
@@ -8,7 +8,7 @@ class Admin::ServicesController < Admin::ApplicationController
...
@@ -8,7 +8,7 @@ class Admin::ServicesController < Admin::ApplicationController
def
index
def
index
@services
=
Service
.
find_or_create_templates
.
sort_by
(
&
:title
)
@services
=
Service
.
find_or_create_templates
.
sort_by
(
&
:title
)
@existing_instance_types
=
Service
.
instances
.
pluck
(
:type
)
# rubocop: disable CodeReuse/ActiveRecord
@existing_instance_types
=
Service
.
for_instance
.
pluck
(
:type
)
# rubocop: disable CodeReuse/ActiveRecord
end
end
def
edit
def
edit
...
...
app/controllers/groups/settings/integrations_controller.rb
View file @
cb38e99d
...
@@ -8,7 +8,7 @@ module Groups
...
@@ -8,7 +8,7 @@ module Groups
before_action
:authorize_admin_group!
before_action
:authorize_admin_group!
def
index
def
index
@integrations
=
Service
.
find_or_initialize_all
(
Service
.
by
_group
(
group
)).
sort_by
(
&
:title
)
@integrations
=
Service
.
find_or_initialize_all
(
Service
.
for
_group
(
group
)).
sort_by
(
&
:title
)
end
end
private
private
...
...
app/models/project.rb
View file @
cb38e99d
...
@@ -2533,11 +2533,11 @@ class Project < ApplicationRecord
...
@@ -2533,11 +2533,11 @@ class Project < ApplicationRecord
end
end
def
services_templates
def
services_templates
@services_templates
||=
Service
.
templates
@services_templates
||=
Service
.
for_template
end
end
def
services_instances
def
services_instances
@services_instances
||=
Service
.
instances
@services_instances
||=
Service
.
for_instance
end
end
def
closest_namespace_setting
(
name
)
def
closest_namespace_setting
(
name
)
...
...
app/models/service.rb
View file @
cb38e99d
...
@@ -63,9 +63,9 @@ class Service < ApplicationRecord
...
@@ -63,9 +63,9 @@ class Service < ApplicationRecord
scope
:active
,
->
{
where
(
active:
true
)
}
scope
:active
,
->
{
where
(
active:
true
)
}
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
:
by
_group
,
->
(
group
)
{
where
(
group_id:
group
,
type:
available_services_types
)
}
scope
:
for
_group
,
->
(
group
)
{
where
(
group_id:
group
,
type:
available_services_types
)
}
scope
:
templates
,
->
{
where
(
template:
true
,
type:
available_services_types
)
}
scope
:
for_template
,
->
{
where
(
template:
true
,
type:
available_services_types
)
}
scope
:
instances
,
->
{
where
(
instance:
true
,
type:
available_services_types
)
}
scope
:
for_instance
,
->
{
where
(
instance:
true
,
type:
available_services_types
)
}
scope
:push_hooks
,
->
{
where
(
push_events:
true
,
active:
true
)
}
scope
:push_hooks
,
->
{
where
(
push_events:
true
,
active:
true
)
}
scope
:tag_push_hooks
,
->
{
where
(
tag_push_events:
true
,
active:
true
)
}
scope
:tag_push_hooks
,
->
{
where
(
tag_push_events:
true
,
active:
true
)
}
...
@@ -291,11 +291,11 @@ class Service < ApplicationRecord
...
@@ -291,11 +291,11 @@ class Service < ApplicationRecord
def
self
.
find_or_create_templates
def
self
.
find_or_create_templates
create_nonexistent_templates
create_nonexistent_templates
templates
for_template
end
end
private_class_method
def
self
.
create_nonexistent_templates
private_class_method
def
self
.
create_nonexistent_templates
nonexistent_services
=
list_nonexistent_services_for
(
templates
)
nonexistent_services
=
list_nonexistent_services_for
(
for_template
)
return
if
nonexistent_services
.
empty?
return
if
nonexistent_services
.
empty?
# Create within a transaction to perform the lowest possible SQL queries.
# Create within a transaction to perform the lowest possible SQL queries.
...
...
spec/features/admin/services/admin_visits_service_templates_spec.rb
View file @
cb38e99d
...
@@ -4,7 +4,7 @@ require 'spec_helper'
...
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec
.
describe
'Admin visits service templates'
do
RSpec
.
describe
'Admin visits service templates'
do
let
(
:admin
)
{
create
(
:user
,
:admin
)
}
let
(
:admin
)
{
create
(
:user
,
:admin
)
}
let
(
:slack_service
)
{
Service
.
templates
.
find
{
|
s
|
s
.
type
==
'SlackService'
}
}
let
(
:slack_service
)
{
Service
.
for_template
.
find
{
|
s
|
s
.
type
==
'SlackService'
}
}
before
do
before
do
sign_in
(
admin
)
sign_in
(
admin
)
...
...
spec/models/service_spec.rb
View file @
cb38e99d
...
@@ -92,12 +92,12 @@ RSpec.describe Service do
...
@@ -92,12 +92,12 @@ RSpec.describe Service do
end
end
end
end
describe
'.
by
_group'
do
describe
'.
for
_group'
do
let!
(
:service1
)
{
create
(
:jira_service
,
project_id:
nil
,
group_id:
group
.
id
)
}
let!
(
:service1
)
{
create
(
:jira_service
,
project_id:
nil
,
group_id:
group
.
id
)
}
let!
(
:service2
)
{
create
(
:jira_service
)
}
let!
(
:service2
)
{
create
(
:jira_service
)
}
it
'returns the right group service'
do
it
'returns the right group service'
do
expect
(
described_class
.
by
_group
(
group
)).
to
match_array
([
service1
])
expect
(
described_class
.
for
_group
(
group
)).
to
match_array
([
service1
])
end
end
end
end
...
@@ -215,11 +215,11 @@ RSpec.describe Service do
...
@@ -215,11 +215,11 @@ RSpec.describe Service do
describe
'.find_or_initialize_all'
do
describe
'.find_or_initialize_all'
do
shared_examples
'service instances'
do
shared_examples
'service instances'
do
it
'returns the available service instances'
do
it
'returns the available service instances'
do
expect
(
Service
.
find_or_initialize_all
(
Service
.
instances
).
pluck
(
:type
)).
to
match_array
(
Service
.
available_services_types
)
expect
(
Service
.
find_or_initialize_all
(
Service
.
for_instance
).
pluck
(
:type
)).
to
match_array
(
Service
.
available_services_types
)
end
end
it
'does not create service instances'
do
it
'does not create service instances'
do
expect
{
Service
.
find_or_initialize_all
(
Service
.
instances
)
}.
not_to
change
{
Service
.
count
}
expect
{
Service
.
find_or_initialize_all
(
Service
.
for_instance
)
}.
not_to
change
{
Service
.
count
}
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