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
7de3ae9c
Commit
7de3ae9c
authored
Jul 08, 2020
by
Brett Walker
Committed by
Michael Kozono
Jul 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Additional specs for jira issue list controller
and handling of exceptions
parent
2f687752
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
33 deletions
+87
-33
ee/app/controllers/projects/integrations/jira/issues_controller.rb
...ntrollers/projects/integrations/jira/issues_controller.rb
+20
-0
ee/app/views/projects/integrations/jira/issues/index.html.haml
...p/views/projects/integrations/jira/issues/index.html.haml
+1
-1
ee/spec/controllers/projects/integrations/jira/issues_controller_spec.rb
...lers/projects/integrations/jira/issues_controller_spec.rb
+66
-32
No files found.
ee/app/controllers/projects/integrations/jira/issues_controller.rb
View file @
7de3ae9c
...
...
@@ -14,6 +14,22 @@ module Projects
end
def
index
respond_to
do
|
format
|
format
.
html
format
.
json
do
render
json:
issues_json
rescue
Projects
::
Integrations
::
Jira
::
IntegrationError
,
Projects
::
Integrations
::
Jira
::
RequestError
=>
e
render_bad_request
(
e
)
end
end
end
private
def
issues_json
jira_issues
=
::
Projects
::
Integrations
::
Jira
::
IssuesFinder
.
new
(
project
,
{}).
execute
::
Integrations
::
Jira
::
IssueSerializer
.
new
.
represent
(
jira_issues
,
project:
project
)
end
protected
...
...
@@ -21,6 +37,10 @@ module Projects
def
check_feature_enabled!
return
render_404
unless
Feature
.
enabled?
(
:jira_integration
,
project
)
end
def
render_bad_request
(
error
)
render
json:
{
errors:
[
error
.
message
]
},
status: :bad_request
end
end
end
end
...
...
ee/app/views/projects/integrations/jira/issues/index.html.haml
View file @
7de3ae9c
-
page_title
_
(
'Jira Issues'
)
.js-issuables-list
{
data:
{
endpoint:
expose_
url
(
api_v4_groups_issues_path
(
id:
@project
.
group
.
id
)),
.js-issuables-list
{
data:
{
endpoint:
expose_
path
(
project_integrations_jira_issues_path
(
@project
,
format: :json
)),
'can-bulk-edit'
:
false
,
'empty-svg-path'
:
image_path
(
'illustrations/issues.svg'
),
'sort-key'
:
@sort
}
}
ee/spec/controllers/projects/integrations/jira/issues_controller_spec.rb
View file @
7de3ae9c
...
...
@@ -9,57 +9,91 @@ RSpec.describe Projects::Integrations::Jira::IssuesController do
let
(
:user
)
{
create
(
:user
)
}
describe
'GET #index'
do
context
'external issue tracker'
do
before
do
sign_in
(
user
)
project
.
add_developer
(
user
)
create
(
:jira_service
,
project:
project
)
end
context
'when jira_integration feature disabled'
do
it
'returns 404 status'
do
stub_feature_flags
(
jira_integration:
false
)
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'renders the "index" template'
do
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
:index
)
end
context
'when project has moved'
do
let
(
:new_project
)
{
create
(
:project
)
}
before
do
sign_in
(
user
)
project
.
add_developer
(
user
)
create
(
:jira_service
,
project:
project
)
project
.
route
.
destroy!
new_project
.
redirect_routes
.
create!
(
path:
project
.
full_path
)
new_project
.
add_developer
(
user
)
end
it
're
nders the "index" templat
e'
do
it
're
directs to the new issue tracker from the old on
e'
do
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
:index
)
expect
(
response
).
to
redirect_to
(
project_integrations_jira_issues_path
(
new_project
)
)
expect
(
response
).
to
have_gitlab_http_status
(
:found
)
end
end
context
'when jira_integration feature disabled'
do
it
'returns 404 status'
do
stub_feature_flags
(
jira_integration:
false
)
context
'json request'
do
let
(
:jira_issues
)
{
[]
}
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
it
'returns a list of serialized jira issues'
do
expect_next_instance_of
(
Projects
::
Integrations
::
Jira
::
IssuesFinder
,
project
,
{})
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
and_return
(
jira_issues
)
end
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect_next_instance_of
(
Integrations
::
Jira
::
IssueSerializer
)
do
|
serializer
|
expect
(
serializer
).
to
receive
(
:represent
).
with
(
jira_issues
,
project:
project
)
end
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
},
format: :json
end
context
'when project has moved'
do
let
(
:new_project
)
{
create
(
:project
)
}
it
'renders bad request for IntegrationError'
do
expect_any_instance_of
(
Projects
::
Integrations
::
Jira
::
IssuesFinder
).
to
receive
(
:execute
)
.
and_raise
(
Projects
::
Integrations
::
Jira
::
IntegrationError
,
'Integration error'
)
before
do
project
.
route
.
destroy!
new_project
.
redirect_routes
.
create!
(
path:
project
.
full_path
)
new_project
.
add_developer
(
user
)
end
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
},
format: :json
it
'redirects to the new issue tracker from the old one'
do
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'errors'
]).
to
eq
[
'Integration error'
]
end
expect
(
response
).
to
redirect_to
(
project_integrations_jira_issues_path
(
new_project
))
expect
(
response
).
to
have_gitlab_http_status
(
:found
)
end
it
'renders bad request for RequestError'
do
expect_any_instance_of
(
Projects
::
Integrations
::
Jira
::
IssuesFinder
).
to
receive
(
:execute
)
.
and_raise
(
Projects
::
Integrations
::
Jira
::
RequestError
,
'Request error'
)
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
},
format: :json
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'errors'
]).
to
eq
[
'Request error'
]
end
end
end
context
'external authorization'
do
before
do
sign_in
user
project
.
add_developer
(
user
)
end
context
'external authorization'
do
before
do
sign_in
user
project
.
add_developer
(
user
)
end
it_behaves_like
'unauthorized when external service denies access'
do
subject
{
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
}
end
it_behaves_like
'unauthorized when external service denies access'
do
subject
{
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
}
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