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
e5db0fce
Commit
e5db0fce
authored
Sep 30, 2020
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue_245303' into 'master'
Block features by issue type See merge request gitlab-org/gitlab!43195
parents
fa53b1e7
3fbeee08
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
91 additions
and
6 deletions
+91
-6
app/models/concerns/issue_available_features.rb
app/models/concerns/issue_available_features.rb
+23
-0
app/models/issue.rb
app/models/issue.rb
+1
-0
ee/app/models/concerns/ee/issuable.rb
ee/app/models/concerns/ee/issuable.rb
+1
-1
ee/app/models/concerns/ee/issue_available_features.rb
ee/app/models/concerns/ee/issue_available_features.rb
+15
-0
ee/spec/models/issue_spec.rb
ee/spec/models/issue_spec.rb
+12
-0
ee/spec/services/ee/notes/quick_actions_service_spec.rb
ee/spec/services/ee/notes/quick_actions_service_spec.rb
+10
-0
ee/spec/services/epics/issue_promote_service_spec.rb
ee/spec/services/epics/issue_promote_service_spec.rb
+21
-5
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+8
-0
No files found.
app/models/concerns/issue_available_features.rb
0 → 100644
View file @
e5db0fce
# frozen_string_literal: true
# Verifies features availability based on issue type.
# This can be used, for example, for hiding UI elements or blocking specific
# quick actions for particular issue types;
module
IssueAvailableFeatures
extend
ActiveSupport
::
Concern
# EE only features are listed on EE::IssueAvailableFeatures
def
available_features_for_issue_types
{}.
with_indifferent_access
end
def
issue_type_supports?
(
feature
)
unless
available_features_for_issue_types
.
has_key?
(
feature
)
raise
ArgumentError
,
'invalid feature'
end
available_features_for_issue_types
[
feature
].
include?
(
issue_type
)
end
end
IssueAvailableFeatures
.
prepend_if_ee
(
'EE::IssueAvailableFeatures'
)
app/models/issue.rb
View file @
e5db0fce
...
...
@@ -20,6 +20,7 @@ class Issue < ApplicationRecord
include
StateEventable
include
IdInOrdered
include
Presentable
include
IssueAvailableFeatures
DueDateStruct
=
Struct
.
new
(
:title
,
:name
).
freeze
NoDueDate
=
DueDateStruct
.
new
(
'No Due Date'
,
'0'
).
freeze
...
...
ee/app/models/concerns/ee/issuable.rb
View file @
e5db0fce
...
...
@@ -6,7 +6,7 @@ module EE
extend
::
Gitlab
::
Utils
::
Override
def
supports_epic?
is_a?
(
Issue
)
&&
!
incident?
&&
project
.
group
.
present?
is_a?
(
Issue
)
&&
issue_type_supports?
(
:epics
)
&&
project
.
group
.
present?
end
def
supports_health_status?
...
...
ee/app/models/concerns/ee/issue_available_features.rb
0 → 100644
View file @
e5db0fce
# frozen_string_literal: true
module
EE
module
IssueAvailableFeatures
include
::
Gitlab
::
Utils
::
StrongMemoize
extend
::
Gitlab
::
Utils
::
Override
override
:available_features_for_issue_types
def
available_features_for_issue_types
strong_memoize
(
:available_features_for_issue_types
)
do
super
.
merge
(
epics:
%w(issue)
)
end
end
end
end
ee/spec/models/issue_spec.rb
View file @
e5db0fce
...
...
@@ -758,4 +758,16 @@ RSpec.describe Issue do
it
{
is_expected
.
to
eq
(
supports_iterations
)
}
end
end
describe
'#issue_type_supports?'
do
let_it_be
(
:issue
)
{
create
(
:issue
)
}
let_it_be
(
:test_case
)
{
create
(
:quality_test_case
)
}
let_it_be
(
:incident
)
{
create
(
:incident
)
}
it
do
expect
(
issue
.
issue_type_supports?
(
:epics
)).
to
be
(
true
)
expect
(
test_case
.
issue_type_supports?
(
:epics
)).
to
be
(
false
)
expect
(
incident
.
issue_type_supports?
(
:epics
)).
to
be
(
false
)
end
end
end
ee/spec/services/ee/notes/quick_actions_service_spec.rb
View file @
e5db0fce
...
...
@@ -121,6 +121,16 @@ RSpec.describe Notes::QuickActionsService do
end
end
context
'on a test case'
do
before
do
issue
.
update!
(
issue_type: :test_case
)
end
it
'leaves the note empty'
do
expect
(
execute
(
note
)).
to
be_empty
end
end
context
'on a merge request'
do
let
(
:note_mr
)
{
create
(
:note_on_merge_request
,
project:
project
,
note:
note_text
)
}
...
...
ee/spec/services/epics/issue_promote_service_spec.rb
View file @
e5db0fce
...
...
@@ -168,14 +168,30 @@ RSpec.describe Epics::IssuePromoteService do
end
end
context
'on an incident'
do
it
'raises error'
do
issue
.
update!
(
issue_type: :incident
)
context
'on other issue types'
do
shared_examples_for
'raising error'
do
before
do
issue
.
update
(
issue_type:
issue_type
)
end
it
'raises error'
do
expect
{
subject
.
execute
(
issue
)
}
.
to
raise_error
(
Epics
::
IssuePromoteService
::
PromoteError
,
/is not supported/
)
end
end
context
'on an incident'
do
let
(
:issue_type
)
{
:incident
}
it_behaves_like
'raising error'
end
context
'on a test case'
do
let
(
:issue_type
)
{
:test_case
}
it_behaves_like
'raising error'
end
end
end
end
end
...
...
spec/models/issue_spec.rb
View file @
e5db0fce
...
...
@@ -1238,4 +1238,12 @@ RSpec.describe Issue do
expect
(
issue
.
allows_reviewers?
).
to
be
(
false
)
end
end
describe
'#issue_type_supports?'
do
let_it_be
(
:issue
)
{
create
(
:issue
)
}
it
'raises error when feature is invalid'
do
expect
{
issue
.
issue_type_supports?
(
:unkown_feature
)
}.
to
raise_error
(
ArgumentError
)
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