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
b754f874
Commit
b754f874
authored
Jun 02, 2020
by
Arturo Herrero
Committed by
Adam Hegyi
Jun 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
List custom integration projects
I've created a new concern to add specific methods related to integrations.
parent
5a94623a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
2 deletions
+54
-2
app/controllers/concerns/integrations_actions.rb
app/controllers/concerns/integrations_actions.rb
+4
-0
app/models/concerns/integration.rb
app/models/concerns/integration.rb
+16
-0
app/models/project.rb
app/models/project.rb
+1
-0
config/routes/admin.rb
config/routes/admin.rb
+1
-0
spec/controllers/admin/integrations_controller_spec.rb
spec/controllers/admin/integrations_controller_spec.rb
+11
-2
spec/models/integration_spec.rb
spec/models/integration_spec.rb
+21
-0
No files found.
app/controllers/concerns/integrations_actions.rb
View file @
b754f874
...
...
@@ -36,6 +36,10 @@ module IntegrationsActions
end
end
def
custom_integration_projects
Project
.
with_custom_integration_compared_to
(
integration
).
page
(
params
[
:page
]).
per
(
20
)
end
def
test
render
json:
{},
status: :ok
end
...
...
app/models/concerns/integration.rb
0 → 100644
View file @
b754f874
# frozen_string_literal: true
module
Integration
extend
ActiveSupport
::
Concern
class_methods
do
def
with_custom_integration_compared_to
(
integration
)
custom_integrations
=
Service
.
select
(
'1'
)
.
where
(
type:
integration
.
type
,
inherit_from_id:
nil
)
.
where
(
'services.project_id = projects.id'
)
Project
.
where
(
'EXISTS (?)'
,
custom_integrations
)
end
end
end
app/models/project.rb
View file @
b754f874
...
...
@@ -33,6 +33,7 @@ class Project < ApplicationRecord
include
OptionallySearch
include
FromUnion
include
IgnorableColumns
include
Integration
extend
Gitlab
::
Cache
::
RequestCache
extend
Gitlab
::
ConfigHelper
...
...
config/routes/admin.rb
View file @
b754f874
...
...
@@ -118,6 +118,7 @@ namespace :admin do
resources
:services
,
only:
[
:index
,
:edit
,
:update
]
resources
:integrations
,
only:
[
:edit
,
:update
]
do
member
do
get
:custom_integration_projects
put
:test
end
end
...
...
spec/controllers/admin/integrations_controller_spec.rb
View file @
b754f874
...
...
@@ -4,6 +4,7 @@ require 'spec_helper'
describe
Admin
::
IntegrationsController
do
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:integration
)
{
create
(
:jira_service
,
:instance
)
}
before
do
sign_in
(
admin
)
...
...
@@ -33,8 +34,6 @@ describe Admin::IntegrationsController do
end
describe
'#update'
do
let
(
:integration
)
{
create
(
:jira_service
,
:instance
)
}
before
do
allow
(
PropagateIntegrationWorker
).
to
receive
(
:perform_async
)
...
...
@@ -68,4 +67,14 @@ describe Admin::IntegrationsController do
end
end
end
describe
'#custom_integration_projects'
do
it
'calls to get the custom integration projects'
do
allow
(
Project
).
to
receive_message_chain
(
:with_custom_integration_compared_to
,
:page
,
:per
)
get
:custom_integration_projects
,
params:
{
id:
integration
.
class
.
to_param
}
expect
(
Project
).
to
have_received
(
:with_custom_integration_compared_to
).
with
(
integration
)
end
end
end
spec/models/integration_spec.rb
0 → 100644
View file @
b754f874
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Integration
do
let
(
:project_1
)
{
create
(
:project
)
}
let
(
:project_2
)
{
create
(
:project
)
}
let
(
:instance_integration
)
{
create
(
:jira_service
,
:instance
)
}
before
do
create
(
:jira_service
,
project:
project_1
,
inherit_from_id:
instance_integration
.
id
)
create
(
:jira_service
,
project:
project_2
,
inherit_from_id:
nil
)
create
(
:slack_service
,
project:
project_1
,
inherit_from_id:
nil
)
end
describe
'#with_custom_integration_compared_to'
do
it
'returns projects with custom integrations'
do
expect
(
Project
.
with_custom_integration_compared_to
(
instance_integration
)).
to
contain_exactly
(
project_2
)
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