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
5131a00f
Commit
5131a00f
authored
Sep 22, 2021
by
Andy Soiron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix events controller spec indentation
parent
b2a333b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
36 deletions
+36
-36
spec/controllers/jira_connect/events_controller_spec.rb
spec/controllers/jira_connect/events_controller_spec.rb
+36
-36
No files found.
spec/controllers/jira_connect/events_controller_spec.rb
View file @
5131a00f
...
@@ -57,58 +57,58 @@ RSpec.describe JiraConnect::EventsController do
...
@@ -57,58 +57,58 @@ RSpec.describe JiraConnect::EventsController do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
end
describe
'#uninstalled'
do
describe
'#uninstalled'
do
let!
(
:installation
)
{
create
(
:jira_connect_installation
)
}
let!
(
:installation
)
{
create
(
:jira_connect_installation
)
}
let
(
:qsh
)
{
Atlassian
::
Jwt
.
create_query_string_hash
(
'https://gitlab.test/events/uninstalled'
,
'POST'
,
'https://gitlab.test'
)
}
let
(
:qsh
)
{
Atlassian
::
Jwt
.
create_query_string_hash
(
'https://gitlab.test/events/uninstalled'
,
'POST'
,
'https://gitlab.test'
)
}
before
do
request
.
headers
[
'Authorization'
]
=
"JWT
#{
auth_token
}
"
end
subject
(
:post_uninstalled
)
{
post
:uninstalled
}
before
do
request
.
headers
[
'Authorization'
]
=
"JWT
#{
auth_token
}
"
end
context
'when JWT is invalid'
do
subject
(
:post_uninstalled
)
{
post
:uninstalled
}
let
(
:auth_token
)
{
'invalid_token'
}
it
'returns 403
'
do
context
'when JWT is invalid
'
do
post_uninstalled
let
(
:auth_token
)
{
'invalid_token'
}
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
it
'returns 403'
do
en
d
post_uninstalle
d
it
'does not delete the installation'
do
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
expect
{
post_uninstalled
}.
not_to
change
{
JiraConnectInstallation
.
count
}
end
end
end
context
'when JWT is valid'
do
it
'does not delete the installation'
do
let
(
:auth_token
)
do
expect
{
post_uninstalled
}.
not_to
change
{
JiraConnectInstallation
.
count
}
Atlassian
::
Jwt
.
encode
({
iss:
installation
.
client_key
,
qsh:
qsh
},
installation
.
shared_secret
)
end
end
end
let
(
:jira_base_path
)
{
'/-/jira_connect'
}
let
(
:jira_event_path
)
{
'/-/jira_connect/events/uninstalled'
}
it
'calls the DestroyService and returns ok in case of success
'
do
context
'when JWT is valid
'
do
expect_next_instance_of
(
JiraConnectInstallations
::
DestroyService
,
installation
,
jira_base_path
,
jira_event_path
)
do
|
destroy_service
|
let
(
:auth_token
)
do
expect
(
destroy_service
).
to
receive
(
:execute
).
and_return
(
true
)
Atlassian
::
Jwt
.
encode
({
iss:
installation
.
client_key
,
qsh:
qsh
},
installation
.
shared_secret
)
end
end
post_uninstalled
let
(
:jira_base_path
)
{
'/-/jira_connect'
}
let
(
:jira_event_path
)
{
'/-/jira_connect/events/uninstalled'
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
it
'calls the DestroyService and returns ok in case of success'
do
expect_next_instance_of
(
JiraConnectInstallations
::
DestroyService
,
installation
,
jira_base_path
,
jira_event_path
)
do
|
destroy_service
|
expect
(
destroy_service
).
to
receive
(
:execute
).
and_return
(
true
)
end
end
it
'calls the DestroyService and returns unprocessable_entity in case of failure'
do
post_uninstalled
expect_next_instance_of
(
JiraConnectInstallations
::
DestroyService
,
installation
,
jira_base_path
,
jira_event_path
)
do
|
destroy_service
|
expect
(
destroy_service
).
to
receive
(
:execute
).
and_return
(
false
)
end
post_uninstalled
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
expect
(
response
).
to
have_gitlab_http_status
(
:unprocessable_entity
)
it
'calls the DestroyService and returns unprocessable_entity in case of failure'
do
expect_next_instance_of
(
JiraConnectInstallations
::
DestroyService
,
installation
,
jira_base_path
,
jira_event_path
)
do
|
destroy_service
|
expect
(
destroy_service
).
to
receive
(
:execute
).
and_return
(
false
)
end
end
post_uninstalled
expect
(
response
).
to
have_gitlab_http_status
(
:unprocessable_entity
)
end
end
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