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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
e6880ebc
Commit
e6880ebc
authored
Aug 22, 2017
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix inability to test some project integrations
parent
539ed0a6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
16 deletions
+40
-16
app/controllers/projects/services_controller.rb
app/controllers/projects/services_controller.rb
+3
-6
changelogs/unreleased/rd-fix-broken-configuration-for-some-integrations.yml
...sed/rd-fix-broken-configuration-for-some-integrations.yml
+5
-0
spec/controllers/projects/services_controller_spec.rb
spec/controllers/projects/services_controller_spec.rb
+32
-10
No files found.
app/controllers/projects/services_controller.rb
View file @
e6880ebc
...
...
@@ -4,7 +4,6 @@ class Projects::ServicesController < Projects::ApplicationController
# Authorize
before_action
:authorize_admin_project!
before_action
:service
,
only:
[
:edit
,
:update
,
:test
]
before_action
:update_service
,
only:
[
:update
,
:test
]
respond_to
:html
...
...
@@ -14,6 +13,8 @@ class Projects::ServicesController < Projects::ApplicationController
end
def
update
@service
.
attributes
=
service_params
[
:service
]
if
@service
.
save
(
context: :manual_change
)
redirect_to
(
project_settings_integrations_path
(
@project
),
notice:
success_message
)
else
...
...
@@ -24,7 +25,7 @@ class Projects::ServicesController < Projects::ApplicationController
def
test
message
=
{}
if
@service
.
can_test?
if
@service
.
can_test?
&&
@service
.
update_attributes
(
service_params
[
:service
])
data
=
@service
.
test_data
(
project
,
current_user
)
outcome
=
@service
.
test
(
data
)
...
...
@@ -50,10 +51,6 @@ class Projects::ServicesController < Projects::ApplicationController
end
end
def
update_service
@service
.
assign_attributes
(
service_params
[
:service
])
end
def
service
@service
||=
@project
.
find_or_initialize_service
(
params
[
:id
])
end
...
...
changelogs/unreleased/rd-fix-broken-configuration-for-some-integrations.yml
0 → 100644
View file @
e6880ebc
---
title
:
Testing of some integrations were broken due to missing ServiceHook record.
merge_request
:
author
:
type
:
fixed
spec/controllers/projects/services_controller_spec.rb
View file @
e6880ebc
...
...
@@ -10,9 +10,6 @@ describe Projects::ServicesController do
before
do
sign_in
(
user
)
project
.
team
<<
[
user
,
:master
]
controller
.
instance_variable_set
(
:@project
,
project
)
controller
.
instance_variable_set
(
:@service
,
service
)
end
describe
'#test'
do
...
...
@@ -20,7 +17,7 @@ describe Projects::ServicesController do
it
'renders 404'
do
allow_any_instance_of
(
Service
).
to
receive
(
:can_test?
).
and_return
(
false
)
put
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
expect
(
response
).
to
have_http_status
(
404
)
end
...
...
@@ -36,7 +33,7 @@ describe Projects::ServicesController do
it
'returns success'
do
allow_any_instance_of
(
MicrosoftTeams
::
Notifier
).
to
receive
(
:ping
).
and_return
(
true
)
put
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
expect
(
response
.
status
).
to
eq
(
200
)
end
...
...
@@ -45,7 +42,7 @@ describe Projects::ServicesController do
it
'returns success'
do
expect
(
HipChat
::
Client
).
to
receive
(
:new
).
with
(
'hipchat_token_p'
,
anything
).
and_return
(
hipchat_client
)
put
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
service:
service_params
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
service:
service_params
expect
(
response
.
status
).
to
eq
(
200
)
end
...
...
@@ -54,17 +51,42 @@ describe Projects::ServicesController do
it
'returns success'
do
expect
(
HipChat
::
Client
).
to
receive
(
:new
).
with
(
'hipchat_token_p'
,
anything
).
and_return
(
hipchat_client
)
put
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
service:
service_params
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
service:
service_params
expect
(
response
.
status
).
to
eq
(
200
)
end
context
'when service is configured for the first time'
do
before
do
allow_any_instance_of
(
ServiceHook
).
to
receive
(
:execute
).
and_return
(
true
)
end
it
'persist the object'
do
do_put
expect
(
BuildkiteService
.
first
).
to
be_present
end
it
'creates the ServiceHook object'
do
do_put
expect
(
BuildkiteService
.
first
.
service_hook
).
to
be_present
end
def
do_put
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
'buildkite'
,
service:
{
'active'
=>
'1'
,
'push_events'
=>
'1'
,
token:
'token'
,
'project_url'
=>
'http://test.com'
}
end
end
end
context
'failure'
do
it
'returns success status code and the error message'
do
expect
(
HipChat
::
Client
).
to
receive
(
:new
).
with
(
'hipchat_token_p'
,
anything
).
and_raise
(
'Bad test'
)
put
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
service:
service_params
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
service:
service_params
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
JSON
.
parse
(
response
.
body
))
...
...
@@ -77,7 +99,7 @@ describe Projects::ServicesController do
context
'when param `active` is set to true'
do
it
'activates the service and redirects to integrations paths'
do
put
:update
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
service:
{
active:
true
}
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
service:
{
active:
true
}
expect
(
response
).
to
redirect_to
(
project_settings_integrations_path
(
project
))
expect
(
flash
[
:notice
]).
to
eq
'HipChat activated.'
...
...
@@ -87,7 +109,7 @@ describe Projects::ServicesController do
context
'when param `active` is set to false'
do
it
'does not activate the service but saves the settings'
do
put
:update
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
service:
{
active:
false
}
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
service:
{
active:
false
}
expect
(
flash
[
:notice
]).
to
eq
'HipChat settings saved, but not activated.'
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