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
ed459753
Commit
ed459753
authored
Dec 12, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop using HipChat in the ServicesController spec
parent
099777a3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
14 deletions
+24
-14
spec/controllers/projects/services_controller_spec.rb
spec/controllers/projects/services_controller_spec.rb
+24
-14
No files found.
spec/controllers/projects/services_controller_spec.rb
View file @
ed459753
...
@@ -3,9 +3,8 @@ require 'spec_helper'
...
@@ -3,9 +3,8 @@ require 'spec_helper'
describe
Projects
::
ServicesController
do
describe
Projects
::
ServicesController
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:service
)
{
create
(
:hipchat_service
,
project:
project
)
}
let
(
:service
)
{
create
(
:jira_service
,
project:
project
)
}
let
(
:hipchat_client
)
{
{
'#room'
=>
double
(
send:
true
)
}
}
let
(
:service_params
)
{
{
username:
'username'
,
password:
'password'
,
url:
'http://example.com'
}
}
let
(
:service_params
)
{
{
token:
'hipchat_token_p'
,
room:
'#room'
}
}
before
do
before
do
sign_in
(
user
)
sign_in
(
user
)
...
@@ -24,13 +23,13 @@ describe Projects::ServicesController do
...
@@ -24,13 +23,13 @@ describe Projects::ServicesController do
end
end
context
'when validations fail'
do
context
'when validations fail'
do
let
(
:service_params
)
{
{
active:
'true'
,
token
:
''
}
}
let
(
:service_params
)
{
{
active:
'true'
,
url
:
''
}
}
it
'returns error messages in JSON response'
do
it
'returns error messages in JSON response'
do
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
:hipchat
,
service:
service_params
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
service:
service_params
expect
(
json_response
[
'message'
]).
to
eq
"Validations failed."
expect
(
json_response
[
'message'
]).
to
eq
"Validations failed."
expect
(
json_response
[
'service_response'
]).
to
eq
"Token
can't be blank"
expect
(
json_response
[
'service_response'
]).
to
include
"Url
can't be blank"
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
end
end
end
...
@@ -52,7 +51,8 @@ describe Projects::ServicesController do
...
@@ -52,7 +51,8 @@ describe Projects::ServicesController do
end
end
it
'returns success'
do
it
'returns success'
do
expect
(
HipChat
::
Client
).
to
receive
(
:new
).
with
(
'hipchat_token_p'
,
anything
).
and_return
(
hipchat_client
)
stub_request
(
:get
,
'http://example.com/rest/api/2/serverInfo'
)
.
to_return
(
status:
200
,
body:
'{}'
)
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
service:
service_params
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
service:
service_params
...
@@ -61,7 +61,8 @@ describe Projects::ServicesController do
...
@@ -61,7 +61,8 @@ describe Projects::ServicesController do
end
end
it
'returns success'
do
it
'returns success'
do
expect
(
HipChat
::
Client
).
to
receive
(
:new
).
with
(
'hipchat_token_p'
,
anything
).
and_return
(
hipchat_client
)
stub_request
(
:get
,
'http://example.com/rest/api/2/serverInfo'
)
.
to_return
(
status:
200
,
body:
'{}'
)
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
service:
service_params
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
service:
service_params
...
@@ -76,12 +77,16 @@ describe Projects::ServicesController do
...
@@ -76,12 +77,16 @@ describe Projects::ServicesController do
it
'persist the object'
do
it
'persist the object'
do
do_put
do_put
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
).
to
be_empty
expect
(
BuildkiteService
.
first
).
to
be_present
expect
(
BuildkiteService
.
first
).
to
be_present
end
end
it
'creates the ServiceHook object'
do
it
'creates the ServiceHook object'
do
do_put
do_put
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
).
to
be_empty
expect
(
BuildkiteService
.
first
.
service_hook
).
to
be_present
expect
(
BuildkiteService
.
first
.
service_hook
).
to
be_present
end
end
...
@@ -96,13 +101,18 @@ describe Projects::ServicesController do
...
@@ -96,13 +101,18 @@ describe Projects::ServicesController do
context
'failure'
do
context
'failure'
do
it
'returns success status code and the error message'
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'
)
stub_request
(
:get
,
'http://example.com/rest/api/2/serverInfo'
)
.
to_return
(
status:
404
)
put
:test
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
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
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
JSON
.
parse
(
response
.
body
))
expect
(
json_response
).
to
eq
(
.
to
eq
(
'error'
=>
true
,
'message'
=>
'Test failed.'
,
'service_response'
=>
'Bad test'
,
'test_failed'
=>
true
)
'error'
=>
true
,
'message'
=>
'Test failed.'
,
'service_response'
=>
''
,
'test_failed'
=>
true
)
end
end
end
end
end
end
...
@@ -114,7 +124,7 @@ describe Projects::ServicesController do
...
@@ -114,7 +124,7 @@ describe Projects::ServicesController do
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
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
(
response
).
to
redirect_to
(
project_settings_integrations_path
(
project
))
expect
(
flash
[
:notice
]).
to
eq
'
HipChat
activated.'
expect
(
flash
[
:notice
]).
to
eq
'
JIRA
activated.'
end
end
end
end
...
@@ -123,7 +133,7 @@ describe Projects::ServicesController do
...
@@ -123,7 +133,7 @@ describe Projects::ServicesController do
put
:update
,
put
:update
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
service
.
to_param
,
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.'
expect
(
flash
[
:notice
]).
to
eq
'
JIRA
settings saved, but not activated.'
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