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