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
9710349c
Commit
9710349c
authored
Jul 08, 2021
by
Luke Duncalfe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Integration#can_test? to #testable?
https://gitlab.com/gitlab-org/gitlab/-/issues/335384
parent
14b6e6c8
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
33 additions
and
52 deletions
+33
-52
app/controllers/projects/services_controller.rb
app/controllers/projects/services_controller.rb
+1
-1
app/helpers/integrations_helper.rb
app/helpers/integrations_helper.rb
+1
-1
app/models/integration.rb
app/models/integration.rb
+1
-1
app/models/integrations/base_slash_commands.rb
app/models/integrations/base_slash_commands.rb
+1
-1
app/models/integrations/confluence.rb
app/models/integrations/confluence.rb
+1
-1
app/models/integrations/ewm.rb
app/models/integrations/ewm.rb
+1
-1
app/models/integrations/jira.rb
app/models/integrations/jira.rb
+1
-1
app/models/integrations/mattermost_slash_commands.rb
app/models/integrations/mattermost_slash_commands.rb
+1
-1
app/models/integrations/mock_ci.rb
app/models/integrations/mock_ci.rb
+1
-1
app/models/integrations/mock_monitoring.rb
app/models/integrations/mock_monitoring.rb
+1
-1
app/models/integrations/pipelines_email.rb
app/models/integrations/pipelines_email.rb
+1
-1
ee/app/models/integrations/github.rb
ee/app/models/integrations/github.rb
+1
-1
ee/app/models/integrations/gitlab_slack_application.rb
ee/app/models/integrations/gitlab_slack_application.rb
+1
-1
ee/spec/models/integrations/github_spec.rb
ee/spec/models/integrations/github_spec.rb
+3
-3
spec/controllers/projects/services_controller_spec.rb
spec/controllers/projects/services_controller_spec.rb
+11
-10
spec/models/integration_spec.rb
spec/models/integration_spec.rb
+5
-7
spec/models/integrations/base_chat_notification_spec.rb
spec/models/integrations/base_chat_notification_spec.rb
+0
-18
spec/models/integrations/jira_spec.rb
spec/models/integrations/jira_spec.rb
+1
-1
No files found.
app/controllers/projects/services_controller.rb
View file @
9710349c
...
...
@@ -46,7 +46,7 @@ class Projects::ServicesController < Projects::ApplicationController
end
def
test
if
integration
.
can_test
?
if
integration
.
testable
?
render
json:
service_test_response
,
status: :ok
else
render
json:
{},
status: :not_found
...
...
app/helpers/integrations_helper.rb
View file @
9710349c
...
...
@@ -84,7 +84,7 @@ module IntegrationsHelper
integration_level:
integration_level
(
integration
),
editable:
integration
.
editable?
.
to_s
,
cancel_path:
scoped_integrations_path
,
can_test:
integration
.
can_test
?
.
to_s
,
can_test:
integration
.
testable
?
.
to_s
,
test_path:
scoped_test_integration_path
(
integration
),
reset_path:
scoped_reset_integration_path
(
integration
,
group:
group
)
}
...
...
app/models/integration.rb
View file @
9710349c
...
...
@@ -447,7 +447,7 @@ class Integration < ApplicationRecord
# Disable test for instance-level and group-level integrations.
# https://gitlab.com/gitlab-org/gitlab/-/issues/213138
def
can_test
?
def
testable
?
project_level?
end
...
...
app/models/integrations/base_slash_commands.rb
View file @
9710349c
...
...
@@ -20,7 +20,7 @@ module Integrations
%w()
end
def
can_test
?
def
testable
?
false
end
...
...
app/models/integrations/confluence.rb
View file @
9710349c
...
...
@@ -58,7 +58,7 @@ module Integrations
]
end
def
can_test
?
def
testable
?
false
end
...
...
app/models/integrations/ewm.rb
View file @
9710349c
...
...
@@ -27,7 +27,7 @@ module Integrations
'ewm'
end
def
can_test
?
def
testable
?
false
end
...
...
app/models/integrations/jira.rb
View file @
9710349c
...
...
@@ -537,7 +537,7 @@ module Integrations
def
update_deployment_type?
(
api_url_changed?
||
url_changed?
||
username_changed?
||
password_changed?
)
&&
can_test
?
testable
?
end
def
update_deployment_type
...
...
app/models/integrations/mattermost_slash_commands.rb
View file @
9710349c
...
...
@@ -6,7 +6,7 @@ module Integrations
prop_accessor
:token
def
can_test
?
def
testable
?
false
end
...
...
app/models/integrations/mock_ci.rb
View file @
9710349c
...
...
@@ -83,7 +83,7 @@ module Integrations
end
end
def
can_test
?
def
testable
?
false
end
end
...
...
app/models/integrations/mock_monitoring.rb
View file @
9710349c
...
...
@@ -18,7 +18,7 @@ module Integrations
Gitlab
::
Json
.
parse
(
File
.
read
(
Rails
.
root
+
'spec/fixtures/metrics.json'
))
end
def
can_test
?
def
testable
?
false
end
end
...
...
app/models/integrations/pipelines_email.rb
View file @
9710349c
...
...
@@ -57,7 +57,7 @@ module Integrations
PipelineNotificationWorker
.
new
.
perform
(
pipeline_id
,
recipients:
all_recipients
)
end
def
can_test
?
def
testable
?
project
&
.
ci_pipelines
&
.
any?
end
...
...
ee/app/models/integrations/github.rb
View file @
9710349c
...
...
@@ -68,7 +68,7 @@ module Integrations
%w(pipeline)
end
def
can_test
?
def
testable
?
project
&
.
ci_pipelines
&
.
any?
end
...
...
ee/app/models/integrations/gitlab_slack_application.rb
View file @
9710349c
...
...
@@ -22,7 +22,7 @@ module Integrations
update
(
active:
!!
slack_integration
)
end
def
can_test
?
def
testable
?
false
end
...
...
ee/spec/models/integrations/github_spec.rb
View file @
9710349c
...
...
@@ -285,17 +285,17 @@ RSpec.describe Integrations::Github do
end
end
describe
'#
can_test
?'
do
describe
'#
testable
?'
do
it
'is false if there are no pipelines'
do
project
.
ci_pipelines
.
delete_all
expect
(
subject
.
can_test?
).
to
eq
fals
e
expect
(
subject
).
not_to
be_testabl
e
end
it
'is true if the project has a pipeline'
do
pipeline
expect
(
subject
.
can_test?
).
to
eq
tru
e
expect
(
subject
).
to
be_testabl
e
end
end
...
...
spec/controllers/projects/services_controller_spec.rb
View file @
9710349c
...
...
@@ -6,9 +6,10 @@ RSpec.describe Projects::ServicesController do
include
JiraServiceHelper
include
AfterNextHelpers
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:service
)
{
create
(
:jira_integration
,
project:
project
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:service
)
{
create
(
:jira_integration
,
project:
project
)
}
let
(
:service_params
)
{
{
username:
'username'
,
password:
'password'
,
url:
'http://example.com'
}
}
before
do
...
...
@@ -17,9 +18,9 @@ RSpec.describe Projects::ServicesController do
end
describe
'#test'
do
context
'when
can_test? returns fals
e'
do
context
'when
the integration is not testabl
e'
do
it
'renders 404'
do
allow_any_instance_of
(
Integration
).
to
receive
(
:
can_test
?
).
and_return
(
false
)
allow_any_instance_of
(
Integration
).
to
receive
(
:
testable
?
).
and_return
(
false
)
put
:test
,
params:
project_params
...
...
@@ -41,10 +42,10 @@ RSpec.describe Projects::ServicesController do
context
'success'
do
context
'with empty project'
do
let
(
:project
)
{
create
(
:project
)
}
let
_it_be
(
:project
)
{
create
(
:project
)
}
context
'with chat notification service'
do
let
(
:service
)
{
project
.
create_microsoft_teams_integration
(
webhook:
'http://webhook.com'
)
}
let
_it_be
(
:service
)
{
project
.
create_microsoft_teams_integration
(
webhook:
'http://webhook.com'
)
}
it
'returns success'
do
allow_next
(
::
MicrosoftTeams
::
Notifier
).
to
receive
(
:ping
).
and_return
(
true
)
...
...
@@ -131,8 +132,7 @@ RSpec.describe Projects::ServicesController do
context
'with the Slack integration'
do
let_it_be
(
:integration
)
{
build
(
:integrations_slack
)
}
let
(
:service
)
{
integration
}
# TODO: remove when https://gitlab.com/gitlab-org/gitlab/-/issues/330300 is complete
let_it_be
(
:service
)
{
integration
}
# TODO: remove when https://gitlab.com/gitlab-org/gitlab/-/issues/330300 is complete
it
'returns an error response when the URL is blocked'
do
put
:test
,
params:
project_params
(
service:
{
webhook:
'http://127.0.0.1'
})
...
...
@@ -259,7 +259,8 @@ RSpec.describe Projects::ServicesController do
end
context
'Prometheus integration'
do
let!
(
:service
)
{
create
(
:prometheus_integration
,
project:
project
)
}
let_it_be
(
:service
)
{
create
(
:prometheus_integration
,
project:
project
)
}
let
(
:service_params
)
{
{
manual_configuration:
'1'
,
api_url:
'http://example.com'
}
}
context
'feature flag :settings_operations_prometheus_service is enabled'
do
...
...
spec/models/integration_spec.rb
View file @
9710349c
...
...
@@ -139,19 +139,17 @@ RSpec.describe Integration do
end
end
describe
'#can_test?'
do
subject
{
integration
.
can_test?
}
describe
'#testable?'
do
context
'when integration is project-level'
do
let
(
:integration
)
{
build
(
:service
,
project:
project
)
}
subject
{
build
(
:service
,
project:
project
)
}
it
{
is_expected
.
to
be
tru
e
}
it
{
is_expected
.
to
be
_testabl
e
}
end
context
'when integration is not project-level'
do
let
(
:integration
)
{
build
(
:service
,
project:
nil
)
}
subject
{
build
(
:service
,
project:
nil
)
}
it
{
is_expected
.
to
be
fals
e
}
it
{
is_expected
.
not_to
be_testabl
e
}
end
end
...
...
spec/models/integrations/base_chat_notification_spec.rb
View file @
9710349c
...
...
@@ -15,24 +15,6 @@ RSpec.describe Integrations::BaseChatNotification do
it
{
is_expected
.
to
validate_inclusion_of
(
:labels_to_be_notified_behavior
).
in_array
(
%w[match_any match_all]
).
allow_blank
}
end
describe
'#can_test?'
do
context
'with empty repository'
do
it
'returns true'
do
subject
.
project
=
create
(
:project
,
:empty_repo
)
expect
(
subject
.
can_test?
).
to
be
true
end
end
context
'with repository'
do
it
'returns true'
do
subject
.
project
=
create
(
:project
,
:repository
)
expect
(
subject
.
can_test?
).
to
be
true
end
end
end
describe
'#execute'
do
subject
(
:chat_integration
)
{
described_class
.
new
}
...
...
spec/models/integrations/jira_spec.rb
View file @
9710349c
...
...
@@ -341,7 +341,7 @@ RSpec.describe Integrations::Jira do
context
'when not allowed to test an instance or group'
do
it
'does not update deployment type'
do
allow
(
integration
).
to
receive
(
:
can_test
?
).
and_return
(
false
)
allow
(
integration
).
to
receive
(
:
testable
?
).
and_return
(
false
)
integration
.
update!
(
url:
'http://first.url'
)
...
...
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