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
117f320f
Commit
117f320f
authored
Mar 20, 2020
by
Justin Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add groups integrations_controller_spec
Mostly copied from admin/integrations_controller_spec.rb
parent
e78faf58
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
107 additions
and
0 deletions
+107
-0
spec/controllers/groups/settings/integrations_controller_spec.rb
...ntrollers/groups/settings/integrations_controller_spec.rb
+107
-0
No files found.
spec/controllers/groups/settings/integrations_controller_spec.rb
0 → 100644
View file @
117f320f
# frozen_string_literal: true
require
'spec_helper'
describe
Groups
::
Settings
::
IntegrationsController
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
let!
(
:project
)
{
create
(
:project
)
}
before
do
sign_in
(
user
)
end
describe
'#edit'
do
context
'when group_level_integrations not enabled'
do
it
'returns not_found'
do
allow
(
Feature
).
to
receive
(
:enabled?
).
with
(
:group_level_integrations
)
{
false
}
get
:edit
,
params:
{
group_id:
group
,
id:
Service
.
available_services_names
.
sample
}
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
'when user is not owner'
do
it
'renders not_found'
do
get
:edit
,
params:
{
group_id:
group
,
id:
Service
.
available_services_names
.
sample
}
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
'when user is owner'
do
before
do
group
.
add_owner
(
user
)
end
Service
.
available_services_names
.
each
do
|
integration_name
|
context
"
#{
integration_name
}
"
do
it
'successfully displays the template'
do
get
:edit
,
params:
{
group_id:
group
,
id:
integration_name
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
:edit
)
end
end
end
end
end
describe
'#update'
do
let
(
:integration
)
{
create
(
:jira_service
,
project:
project
)
}
before
do
group
.
add_owner
(
user
)
put
:update
,
params:
{
group_id:
group
,
id:
integration
.
class
.
to_param
,
service:
{
url:
url
}
}
end
context
'valid params'
do
let
(
:url
)
{
'https://jira.gitlab-example.com'
}
it
'updates the integration'
do
expect
(
response
).
to
have_gitlab_http_status
(
:found
)
expect
(
integration
.
reload
.
url
).
to
eq
(
url
)
end
end
context
'invalid params'
do
let
(
:url
)
{
'ftp://jira.localhost'
}
it
'does not update the integration'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
:edit
)
expect
(
integration
.
reload
.
url
).
not_to
eq
(
url
)
end
end
end
describe
'#test'
do
context
'testable'
do
let
(
:integration
)
{
create
(
:jira_service
,
project:
project
)
}
before
do
group
.
add_owner
(
user
)
end
it
'returns ok'
do
allow_any_instance_of
(
integration
.
class
).
to
receive
(
:test
)
{
{
success:
true
}
}
put
:test
,
params:
{
group_id:
group
,
id:
integration
.
class
.
to_param
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
context
'not testable'
do
let
(
:integration
)
{
create
(
:alerts_service
,
project:
project
)
}
it
'returns not found'
do
put
:test
,
params:
{
group_id:
group
,
id:
integration
.
class
.
to_param
}
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
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