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
9e760b44
Commit
9e760b44
authored
May 21, 2021
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable time tracking only for issues and incidents
Adds :time_tracking feature to allow list
parent
23551042
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
119 additions
and
1 deletion
+119
-1
app/models/concerns/issue_available_features.rb
app/models/concerns/issue_available_features.rb
+2
-1
app/models/issue.rb
app/models/issue.rb
+4
-0
ee/spec/factories/issues.rb
ee/spec/factories/issues.rb
+9
-0
ee/spec/models/issue_spec.rb
ee/spec/models/issue_spec.rb
+20
-0
ee/spec/services/ee/notes/quick_actions_service_spec.rb
ee/spec/services/ee/notes/quick_actions_service_spec.rb
+44
-0
lib/gitlab/quick_actions/issue_and_merge_request_actions.rb
lib/gitlab/quick_actions/issue_and_merge_request_actions.rb
+2
-0
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+22
-0
spec/services/notes/quick_actions_service_spec.rb
spec/services/notes/quick_actions_service_spec.rb
+16
-0
No files found.
app/models/concerns/issue_available_features.rb
View file @
9e760b44
...
...
@@ -11,7 +11,8 @@ module IssueAvailableFeatures
def
available_features_for_issue_types
{
assignee:
%w(issue incident)
,
confidentiality:
%(issue incident)
confidentiality:
%(issue incident)
,
time_tracking:
%(issue incident)
}.
with_indifferent_access
end
end
...
...
app/models/issue.rb
View file @
9e760b44
...
...
@@ -464,6 +464,10 @@ class Issue < ApplicationRecord
issue_type_supports?
(
:assignee
)
end
def
supports_time_tracking?
issue_type_supports?
(
:time_tracking
)
end
def
email_participants_emails
issue_email_participants
.
pluck
(
:email
)
end
...
...
ee/spec/factories/issues.rb
View file @
9e760b44
...
...
@@ -10,6 +10,15 @@ FactoryBot.modify do
end
end
# There is another factory called :requirement for RequirementManagement::Requirement.
# We are converting that class into an issue type. We can rename this as :requirement
# when migration is completed. More information at https://gitlab.com/gitlab-org/gitlab/-/issues/323779
FactoryBot
.
define
do
factory
:requirement_issue
,
parent: :issue
do
issue_type
{
:requirement
}
end
end
FactoryBot
.
define
do
factory
:quality_test_case
,
parent: :issue
do
issue_type
{
:test_case
}
...
...
ee/spec/models/issue_spec.rb
View file @
9e760b44
...
...
@@ -1019,6 +1019,26 @@ RSpec.describe Issue do
end
end
describe
'#supports_time_tracking?'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be_with_refind
(
:issue
)
{
create
(
:incident
,
project:
project
)
}
where
(
:issue_type
,
:supports_time_tracking
)
do
:requirement
|
false
:test_case
|
false
end
with_them
do
before
do
issue
.
update!
(
issue_type:
issue_type
)
end
it
do
expect
(
issue
.
supports_time_tracking?
).
to
eq
(
supports_time_tracking
)
end
end
end
describe
'.with_issue_type'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
...
...
ee/spec/services/ee/notes/quick_actions_service_spec.rb
View file @
9e760b44
...
...
@@ -486,4 +486,48 @@ RSpec.describe Notes::QuickActionsService do
end
end
end
context
'with issue types'
do
shared_examples
'note on issue type that does not support time tracking'
do
let
(
:note
)
{
build
(
:note_on_issue
,
project:
project
,
noteable:
noteable
)
}
before
do
note
.
note
=
note_text
end
context
'/spend'
do
let
(
:note_text
)
{
"/spend 1h 2021-05-26"
}
it
'does not change time spent'
do
expect
{
execute
(
note
)
}.
not_to
change
{
noteable
.
reload
.
time_spent
}
end
end
context
'/estimate'
do
let
(
:note_text
)
{
"/estimate 1h"
}
it
'does not execute time estimate'
do
expect
{
execute
(
note
)
}.
not_to
change
{
noteable
.
reload
.
time_estimate
}
end
end
end
context
'when issue does not support quick actions'
do
before
do
group
.
add_developer
(
user
)
end
context
'for requirement'
do
it_behaves_like
'note on issue type that does not support time tracking'
do
let
(
:noteable
)
{
create
(
:requirement_issue
,
project:
project
)
}
end
end
context
'for test case'
do
it_behaves_like
'note on issue type that does not support time tracking'
do
let
(
:noteable
)
{
create
(
:quality_test_case
,
project:
project
)
}
end
end
end
end
end
lib/gitlab/quick_actions/issue_and_merge_request_actions.rb
View file @
9e760b44
...
...
@@ -155,6 +155,7 @@ module Gitlab
params
'<1w 3d 2h 14m>'
types
Issue
,
MergeRequest
condition
do
quick_action_target
.
supports_time_tracking?
&&
current_user
.
can?
(
:"admin_
#{
quick_action_target
.
to_ability_name
}
"
,
project
)
end
parse_params
do
|
raw_duration
|
...
...
@@ -177,6 +178,7 @@ module Gitlab
params
'<time(1h30m | -1h30m)> <date(YYYY-MM-DD)>'
types
Issue
,
MergeRequest
condition
do
quick_action_target
.
supports_time_tracking?
&&
current_user
.
can?
(
:"admin_
#{
quick_action_target
.
to_ability_name
}
"
,
quick_action_target
)
end
parse_params
do
|
raw_time_date
|
...
...
spec/models/issue_spec.rb
View file @
9e760b44
...
...
@@ -5,6 +5,8 @@ require 'spec_helper'
RSpec
.
describe
Issue
do
include
ExternalAuthorizationServiceHelpers
using
RSpec
::
Parameterized
::
TableSyntax
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:reusable_project
)
{
create
(
:project
)
}
...
...
@@ -1333,6 +1335,26 @@ RSpec.describe Issue do
end
end
describe
'#supports_time_tracking?'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be_with_refind
(
:issue
)
{
create
(
:incident
,
project:
project
)
}
where
(
:issue_type
,
:supports_time_tracking
)
do
:issue
|
true
:incident
|
true
end
with_them
do
before
do
issue
.
update!
(
issue_type:
issue_type
)
end
it
do
expect
(
issue
.
supports_time_tracking?
).
to
eq
(
supports_time_tracking
)
end
end
end
describe
'#email_participants_emails'
do
let_it_be
(
:issue
)
{
create
(
:issue
)
}
...
...
spec/services/notes/quick_actions_service_spec.rb
View file @
9e760b44
...
...
@@ -130,6 +130,17 @@ RSpec.describe Notes::QuickActionsService do
end
end
describe
'/estimate'
do
let
(
:note_text
)
{
'/estimate 1h'
}
it
'adds time estimate to noteable'
do
content
=
execute
(
note
)
expect
(
content
).
to
be_empty
expect
(
note
.
noteable
.
time_estimate
).
to
eq
(
3600
)
end
end
describe
'note with command & text'
do
describe
'/close, /label, /assign & /milestone'
do
let
(
:note_text
)
do
...
...
@@ -301,6 +312,11 @@ RSpec.describe Notes::QuickActionsService do
let
(
:note
)
{
build
(
:note_on_issue
,
project:
project
,
noteable:
issue
)
}
end
it_behaves_like
'note on noteable that supports quick actions'
do
let_it_be
(
:incident
,
reload:
true
)
{
create
(
:incident
,
project:
project
)
}
let
(
:note
)
{
build
(
:note_on_issue
,
project:
project
,
noteable:
incident
)
}
end
it_behaves_like
'note on noteable that supports quick actions'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:note
)
{
build
(
:note_on_merge_request
,
project:
project
,
noteable:
merge_request
)
}
...
...
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