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
19c8b993
Commit
19c8b993
authored
Jan 13, 2021
by
Arturo Herrero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve jira issues controller and specs
parent
448760eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
30 deletions
+20
-30
ee/app/controllers/projects/integrations/jira/issues_controller.rb
...ntrollers/projects/integrations/jira/issues_controller.rb
+8
-9
ee/spec/controllers/projects/integrations/jira/issues_controller_spec.rb
...lers/projects/integrations/jira/issues_controller_spec.rb
+12
-21
No files found.
ee/app/controllers/projects/integrations/jira/issues_controller.rb
View file @
19c8b993
...
...
@@ -34,8 +34,11 @@ module Projects
private
def
issues_json
jira_issues
=
finder
.
execute
jira_issues
=
Kaminari
.
paginate_array
(
jira_issues
,
limit:
finder
.
per_page
,
total_count:
finder
.
total_count
)
jira_issues
=
Kaminari
.
paginate_array
(
finder
.
execute
,
limit:
finder
.
per_page
,
total_count:
finder
.
total_count
)
::
Integrations
::
Jira
::
IssueSerializer
.
new
.
with_pagination
(
request
,
response
)
...
...
@@ -43,11 +46,7 @@ module Projects
end
def
finder
@finder
||=
finder_type
.
new
(
project
,
finder_options
)
end
def
finder_type
::
Projects
::
Integrations
::
Jira
::
IssuesFinder
@finder
||=
::
Projects
::
Integrations
::
Jira
::
IssuesFinder
.
new
(
project
,
finder_options
)
end
def
finder_options
...
...
@@ -56,7 +55,7 @@ module Projects
# Used by view to highlight active option
@sort
=
options
[
:sort
]
params
.
permit
(
finder_type
.
valid_params
).
merge
(
options
)
params
.
permit
(
::
Projects
::
Integrations
::
Jira
::
IssuesFinder
.
valid_params
).
merge
(
options
)
end
def
default_state
...
...
@@ -74,7 +73,7 @@ module Projects
protected
def
check_feature_enabled!
return
render_404
unless
project
.
jira_issues_integration_available?
&&
project
.
external_issue_tracker
return
render_404
unless
project
.
jira_issues_integration_available?
&&
project
.
jira_service
.
issues_enabled
end
# Return the informational message to the user
...
...
ee/spec/controllers/projects/integrations/jira/issues_controller_spec.rb
View file @
19c8b993
...
...
@@ -5,30 +5,33 @@ require 'spec_helper'
RSpec
.
describe
Projects
::
Integrations
::
Jira
::
IssuesController
do
include
ProjectForksHelper
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
_it_be
(
:project
)
{
create
(
:project
)
}
let
_it_be
(
:user
)
{
create
(
:user
)
}
before
do
stub_licensed_features
(
jira_issues_integration:
true
)
sign_in
(
user
)
project
.
add_developer
(
user
)
create
(
:jira_service
,
project:
project
,
issues_enabled:
true
,
project_key:
'TEST'
)
end
describe
'GET #index'
do
before
do
sign_in
(
user
)
project
.
add_developer
(
user
)
create
(
:jira_service
,
project:
project
)
end
context
'when jira_issues_integration licensed feature is not available'
do
it
'returns 404 status'
do
before
do
stub_licensed_features
(
jira_issues_integration:
false
)
end
it
'returns 404 status'
do
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it_behaves_like
'unauthorized when external service denies access'
do
subject
{
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
}
end
it
'renders the "index" template'
do
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
...
...
@@ -170,16 +173,4 @@ RSpec.describe Projects::Integrations::Jira::IssuesController do
end
end
end
context
'external authorization'
do
before
do
sign_in
user
project
.
add_developer
(
user
)
create
(
:jira_service
,
project:
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