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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
f9963fe0
Commit
f9963fe0
authored
Dec 21, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse JIRA issue references even if Issue Tracker is disabled
parent
7e88b242
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
41 deletions
+52
-41
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+16
-37
app/policies/project_policy.rb
app/policies/project_policy.rb
+10
-3
changelogs/unreleased/issue_25682.yml
changelogs/unreleased/issue_25682.yml
+4
-0
spec/features/projects/features_visibility_spec.rb
spec/features/projects/features_visibility_spec.rb
+11
-0
spec/lib/banzai/reference_parser/external_issue_parser_spec.rb
...lib/banzai/reference_parser/external_issue_parser_spec.rb
+11
-1
No files found.
app/helpers/projects_helper.rb
View file @
f9963fe0
...
@@ -171,48 +171,27 @@ module ProjectsHelper
...
@@ -171,48 +171,27 @@ module ProjectsHelper
nav_tabs
<<
:merge_requests
nav_tabs
<<
:merge_requests
end
end
if
can?
(
current_user
,
:read_pipeline
,
project
)
nav_tabs
<<
:pipelines
end
if
can?
(
current_user
,
:read_build
,
project
)
nav_tabs
<<
:builds
end
if
Gitlab
.
config
.
registry
.
enabled
&&
can?
(
current_user
,
:read_container_image
,
project
)
if
Gitlab
.
config
.
registry
.
enabled
&&
can?
(
current_user
,
:read_container_image
,
project
)
nav_tabs
<<
:container_registry
nav_tabs
<<
:container_registry
end
end
if
can?
(
current_user
,
:read_environment
,
project
)
tab_ability_map
=
{
nav_tabs
<<
:environments
environments: :read_environment
,
end
milestones: :read_milestone
,
pipelines: :read_pipeline
,
if
can?
(
current_user
,
:admin_project
,
project
)
snippets: :read_project_snippet
,
nav_tabs
<<
:settings
settings: :admin_project
,
end
builds: :read_build
,
labels: :read_label
,
if
can?
(
current_user
,
:read_project_member
,
project
)
issues: :read_issue
,
nav_tabs
<<
:team
team: :read_project_member
,
end
wiki: :read_wiki
}
if
can?
(
current_user
,
:read_issue
,
project
)
nav_tabs
<<
:issues
end
if
can?
(
current_user
,
:read_wiki
,
project
)
nav_tabs
<<
:wiki
end
if
can?
(
current_user
,
:read_project_snippet
,
project
)
nav_tabs
<<
:snippets
end
if
can?
(
current_user
,
:read_label
,
project
)
tab_ability_map
.
each
do
|
tab
,
ability
|
nav_tabs
<<
:labels
if
can?
(
current_user
,
ability
,
project
)
nav_tabs
<<
tab
end
end
if
can?
(
current_user
,
:read_milestone
,
project
)
nav_tabs
<<
:milestones
end
end
nav_tabs
.
flatten
nav_tabs
.
flatten
...
...
app/policies/project_policy.rb
View file @
f9963fe0
...
@@ -171,9 +171,7 @@ class ProjectPolicy < BasePolicy
...
@@ -171,9 +171,7 @@ class ProjectPolicy < BasePolicy
def
disabled_features!
def
disabled_features!
repository_enabled
=
project
.
feature_available?
(
:repository
,
user
)
repository_enabled
=
project
.
feature_available?
(
:repository
,
user
)
unless
project
.
feature_available?
(
:issues
,
user
)
block_issues_abilities
cannot!
(
*
named_abilities
(
:issue
))
end
unless
project
.
feature_available?
(
:merge_requests
,
user
)
&&
repository_enabled
unless
project
.
feature_available?
(
:merge_requests
,
user
)
&&
repository_enabled
cannot!
(
*
named_abilities
(
:merge_request
))
cannot!
(
*
named_abilities
(
:merge_request
))
...
@@ -250,6 +248,15 @@ class ProjectPolicy < BasePolicy
...
@@ -250,6 +248,15 @@ class ProjectPolicy < BasePolicy
)
)
end
end
def
block_issues_abilities
unless
project
.
feature_available?
(
:issues
,
user
)
cannot!
:read_issue
if
project
.
default_issues_tracker?
cannot!
:create_issue
cannot!
:update_issue
cannot!
:admin_issue
end
end
def
named_abilities
(
name
)
def
named_abilities
(
name
)
[
[
:"read_
#{
name
}
"
,
:"read_
#{
name
}
"
,
...
...
changelogs/unreleased/issue_25682.yml
0 → 100644
View file @
f9963fe0
---
title
:
Parse JIRA issue references even if Issue Tracker is disabled
merge_request
:
author
:
spec/features/projects/features_visibility_spec.rb
View file @
f9963fe0
...
@@ -42,6 +42,17 @@ describe 'Edit Project Settings', feature: true do
...
@@ -42,6 +42,17 @@ describe 'Edit Project Settings', feature: true do
end
end
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
)
allow_any_instance_of
(
Project
).
to
receive
(
:external_issue_tracker
).
and_return
(
JiraService
.
new
)
visit
namespace_project_path
(
project
.
namespace
,
project
)
expect
(
page
).
to
have_selector
(
".shortcuts-issues"
)
end
end
context
"pipelines subtabs"
do
context
"pipelines subtabs"
do
it
"shows builds when enabled"
do
it
"shows builds when enabled"
do
visit
namespace_project_pipelines_path
(
project
.
namespace
,
project
)
visit
namespace_project_pipelines_path
(
project
.
namespace
,
project
)
...
...
spec/lib/banzai/reference_parser/external_issue_parser_spec.rb
View file @
f9963fe0
...
@@ -12,7 +12,17 @@ describe Banzai::ReferenceParser::ExternalIssueParser, lib: true do
...
@@ -12,7 +12,17 @@ describe Banzai::ReferenceParser::ExternalIssueParser, lib: true do
context
'when the link has a data-issue attribute'
do
context
'when the link has a data-issue attribute'
do
before
{
link
[
'data-external-issue'
]
=
123
}
before
{
link
[
'data-external-issue'
]
=
123
}
it_behaves_like
"referenced feature visibility"
,
"issues"
levels
=
[
ProjectFeature
::
DISABLED
,
ProjectFeature
::
PRIVATE
,
ProjectFeature
::
ENABLED
]
levels
.
each
do
|
level
|
it
"creates reference when the feature is
#{
level
}
"
do
project
.
project_feature
.
update
(
issues_access_level:
level
)
visible_nodes
=
subject
.
nodes_visible_to_user
(
user
,
[
link
])
expect
(
visible_nodes
).
to
include
(
link
)
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