BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
2fa22a07
Commit
2fa22a07
authored
Jun 13, 2017
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Associate Issues tab only with internal issues tracker
parent
b92d5135
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
31 deletions
+91
-31
issues_controller.rb
app/controllers/projects/issues_controller.rb
+8
-5
project_policy.rb
app/policies/project_policy.rb
+0
-3
33097-issue-tracker.yml
changelogs/unreleased/33097-issue-tracker.yml
+4
-0
issues_controller_spec.rb
spec/controllers/projects/issues_controller_spec.rb
+40
-19
features_visibility_spec.rb
spec/features/projects/features_visibility_spec.rb
+15
-4
project_policy_spec.rb
spec/policies/project_policy_spec.rb
+24
-0
No files found.
app/controllers/projects/issues_controller.rb
View file @
2fa22a07
...
...
@@ -8,7 +8,6 @@ class Projects::IssuesController < Projects::ApplicationController
prepend_before_action
:authenticate_user!
,
only:
[
:new
]
before_action
:redirect_to_external_issue_tracker
,
only:
[
:index
,
:new
]
before_action
:check_issues_available!
before_action
:issue
,
except:
[
:index
,
:new
,
:create
,
:bulk_update
]
...
...
@@ -243,19 +242,19 @@ class Projects::IssuesController < Projects::ApplicationController
end
def
authorize_update_issue!
re
turn
re
nder_404
unless
can?
(
current_user
,
:update_issue
,
@issue
)
render_404
unless
can?
(
current_user
,
:update_issue
,
@issue
)
end
def
authorize_admin_issues!
re
turn
re
nder_404
unless
can?
(
current_user
,
:admin_issue
,
@project
)
render_404
unless
can?
(
current_user
,
:admin_issue
,
@project
)
end
def
authorize_create_merge_request!
re
turn
re
nder_404
unless
can?
(
current_user
,
:push_code
,
@project
)
&&
@issue
.
can_be_worked_on?
(
current_user
)
render_404
unless
can?
(
current_user
,
:push_code
,
@project
)
&&
@issue
.
can_be_worked_on?
(
current_user
)
end
def
check_issues_available!
return
render_404
unless
@project
.
feature_available?
(
:issues
,
current_user
)
&&
@project
.
default_issues_tracker?
return
render_404
unless
@project
.
feature_available?
(
:issues
,
current_user
)
end
def
redirect_to_external_issue_tracker
...
...
@@ -270,6 +269,10 @@ class Projects::IssuesController < Projects::ApplicationController
end
end
def
module_enabled
render_404
unless
@project
.
feature_available?
(
:issues
,
current_user
)
end
def
issue_params
params
.
require
(
:issue
).
permit
(
*
issue_params_attributes
)
end
...
...
app/policies/project_policy.rb
View file @
2fa22a07
...
...
@@ -287,9 +287,6 @@ class ProjectPolicy < BasePolicy
prevent
:create_issue
prevent
:update_issue
prevent
:admin_issue
end
rule
{
issues_disabled
&
default_issues_tracker
}.
policy
do
prevent
:read_issue
end
...
...
changelogs/unreleased/33097-issue-tracker.yml
0 → 100644
View file @
2fa22a07
---
title
:
Associate Issues tab only with internal issues tracker
merge_request
:
author
:
spec/controllers/projects/issues_controller_spec.rb
View file @
2fa22a07
...
...
@@ -7,16 +7,30 @@ describe Projects::IssuesController do
describe
"GET #index"
do
context
'external issue tracker'
do
let!
(
:service
)
do
create
(
:custom_issue_tracker_service
,
project:
project
,
title:
'Custom Issue Tracker'
,
project_url:
'http://test.com'
)
before
do
sign_in
(
user
)
project
.
add_developer
(
user
)
create
(
:jira_service
,
project:
project
)
end
it
'redirects to the external issue tracker'
do
controller
.
instance_variable_set
(
:@project
,
project
)
context
'when GitLab issues disabled'
do
it
'returns 404 status'
do
project
.
issues_enabled
=
false
project
.
save!
get
:index
,
namespace_id:
project
.
namespace
,
project_id:
project
get
:index
,
namespace_id:
project
.
namespace
,
project_id:
project
expect
(
response
).
to
have_http_status
(
404
)
end
end
context
'when GitLab issues enabled'
do
it
'renders the "index" template'
do
get
:index
,
namespace_id:
project
.
namespace
,
project_id:
project
expect
(
response
).
to
redirect_to
(
service
.
issue_tracker_path
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
render_template
(
:index
)
end
end
end
...
...
@@ -42,15 +56,7 @@ describe Projects::IssuesController do
it
"returns 404 when issues are disabled"
do
project
.
issues_enabled
=
false
project
.
save
get
:index
,
namespace_id:
project
.
namespace
,
project_id:
project
expect
(
response
).
to
have_http_status
(
404
)
end
it
"returns 404 when external issue tracker is enabled"
do
controller
.
instance_variable_set
(
:@project
,
project
)
allow
(
project
).
to
receive
(
:default_issues_tracker?
).
and_return
(
false
)
project
.
save!
get
:index
,
namespace_id:
project
.
namespace
,
project_id:
project
expect
(
response
).
to
have_http_status
(
404
)
...
...
@@ -148,14 +154,29 @@ describe Projects::IssuesController do
before
do
sign_in
(
user
)
project
.
team
<<
[
user
,
:developer
]
external
=
double
allow
(
project
).
to
receive
(
:external_issue_tracker
).
and_return
(
external
)
end
it
'redirects to the external issue tracker'
do
controller
.
instance_variable_set
(
:@project
,
project
)
context
'when GitLab issues disabled'
do
it
'returns 404 status'
do
project
.
issues_enabled
=
false
project
.
save!
get
:new
,
namespace_id:
project
.
namespace
,
project_id:
project
get
:new
,
namespace_id:
project
.
namespace
,
project_id:
project
expect
(
response
).
to
redirect_to
(
'http://test.com'
)
expect
(
response
).
to
have_http_status
(
404
)
end
end
context
'when GitLab issues enabled'
do
it
'renders the "new" template'
do
get
:new
,
namespace_id:
project
.
namespace
,
project_id:
project
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
render_template
(
:new
)
end
end
end
end
...
...
spec/features/projects/features_visibility_spec.rb
View file @
2fa22a07
...
...
@@ -39,14 +39,25 @@ describe 'Edit Project Settings', feature: true do
end
end
context
"When external issue tracker is enabled"
do
it
"does not hide issues tab"
do
project
.
project_feature
.
update
(
issues_access_level:
ProjectFeature
::
DISABLED
)
context
'When external issue tracker is enabled and issues enabled on project settings'
do
it
'does not hide issues tab'
do
allow_any_instance_of
(
Project
).
to
receive
(
:external_issue_tracker
).
and_return
(
JiraService
.
new
)
visit
project_path
(
project
)
expect
(
page
).
to
have_selector
(
".shortcuts-issues"
)
expect
(
page
).
to
have_selector
(
'.shortcuts-issues'
)
end
end
context
'When external issue tracker is enabled and issues disabled on project settings'
do
it
'hides issues tab'
do
project
.
issues_enabled
=
false
project
.
save!
allow_any_instance_of
(
Project
).
to
receive
(
:external_issue_tracker
).
and_return
(
JiraService
.
new
)
visit
namespace_project_path
(
project
.
namespace
,
project
)
expect
(
page
).
not_to
have_selector
(
'.shortcuts-issues'
)
end
end
...
...
spec/policies/project_policy_spec.rb
View file @
2fa22a07
...
...
@@ -103,6 +103,30 @@ describe ProjectPolicy, models: true do
end
end
context
'issues feature'
do
subject
{
described_class
.
new
(
owner
,
project
)
}
context
'when the feature is disabled'
do
it
'does not include the issues permissions'
do
project
.
issues_enabled
=
false
project
.
save!
expect_disallowed
:read_issue
,
:create_issue
,
:update_issue
,
:admin_issue
end
end
context
'when the feature is disabled and external tracker configured'
do
it
'does not include the issues permissions'
do
create
(
:jira_service
,
project:
project
)
project
.
issues_enabled
=
false
project
.
save!
expect_disallowed
:read_issue
,
:create_issue
,
:update_issue
,
:admin_issue
end
end
end
context
'abilities for non-public projects'
do
let
(
:project
)
{
create
(
:empty_project
,
namespace:
owner
.
namespace
)
}
...
...
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