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
09b02e66
Commit
09b02e66
authored
Nov 10, 2016
by
Ruben Davila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to remove the time spent through the `remove_time_spent` command.
parent
02a2422e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
4 deletions
+34
-4
app/models/concerns/time_trackable.rb
app/models/concerns/time_trackable.rb
+3
-1
app/services/slash_commands/interpret_service.rb
app/services/slash_commands/interpret_service.rb
+9
-0
app/services/system_note_service.rb
app/services/system_note_service.rb
+8
-3
doc/user/project/slash_commands.md
doc/user/project/slash_commands.md
+1
-0
spec/services/slash_commands/interpret_service_spec.rb
spec/services/slash_commands/interpret_service_spec.rb
+13
-0
No files found.
app/models/concerns/time_trackable.rb
View file @
09b02e66
...
...
@@ -17,7 +17,9 @@ module TimeTrackable
def
spend_time
=
(
seconds
)
return
unless
seconds
timelogs
.
new
(
time_spent:
seconds
)
new_time_spent
=
seconds
.
zero?
?
-
(
total_time_spent
)
:
seconds
timelogs
.
new
(
time_spent:
new_time_spent
)
@time_spent
=
seconds
end
...
...
app/services/slash_commands/interpret_service.rb
View file @
09b02e66
...
...
@@ -284,6 +284,15 @@ module SlashCommands
@updates
[
:time_estimate
]
=
0
end
desc
'Remove the time spent'
condition
do
issuable
.
persisted?
&&
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
end
command
:remove_time_spent
do
@updates
[
:spend_time
]
=
0
end
def
find_label_ids
(
labels_param
)
label_ids_by_reference
=
extract_references
(
labels_param
,
:label
).
map
(
&
:id
)
labels_ids_by_name
=
LabelsFinder
.
new
(
current_user
,
project_id:
project
.
id
,
name:
labels_param
.
split
).
execute
.
select
(
:id
)
...
...
app/services/system_note_service.rb
View file @
09b02e66
...
...
@@ -150,9 +150,14 @@ module SystemNoteService
def
change_time_spent
(
noteable
,
project
,
author
)
time_spent
=
noteable
.
time_spent
parsed_time
=
ChronicDuration
.
output
(
time_spent
.
abs
,
format: :short
)
action
=
time_spent
>
0
?
'Added'
:
'Substracted'
body
=
"
#{
action
}
#{
parsed_time
}
of time spent on this
#{
noteable
.
human_class_name
}
"
if
time_spent
.
zero?
body
=
"Removed time spent on this
#{
noteable
.
human_class_name
}
"
else
parsed_time
=
ChronicDuration
.
output
(
time_spent
.
abs
,
format: :short
)
action
=
time_spent
>
0
?
'Added'
:
'Substracted'
body
=
"
#{
action
}
#{
parsed_time
}
of time spent on this
#{
noteable
.
human_class_name
}
"
end
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
...
...
doc/user/project/slash_commands.md
View file @
09b02e66
...
...
@@ -32,3 +32,4 @@ do.
|
<code>
/estimate
<
1w 3d 2h 14m
>
</code>
| Set time estimate |
|
`/remove_estimation`
| Remove estimated time |
|
<code>
/spend
<
1h 30m
|
-1h 5m
>
</code>
| Add or substract spent time |
|
`/remove_time_spent`
| Remove time spent |
spec/services/slash_commands/interpret_service_spec.rb
View file @
09b02e66
...
...
@@ -234,6 +234,14 @@ describe SlashCommands::InterpretService, services: true do
end
end
shared_examples
'remove_time_spent command'
do
it
'populates spend_time: "0" if content contains /remove_time_spent'
do
_
,
updates
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
).
to
eq
(
spend_time:
0
)
end
end
shared_examples
'empty command'
do
it
'populates {} if content contains an unsupported command'
do
_
,
updates
=
service
.
execute
(
content
,
issuable
)
...
...
@@ -510,6 +518,11 @@ describe SlashCommands::InterpretService, services: true do
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'remove_time_spent command'
do
let
(
:content
)
{
'/remove_time_spent'
}
let
(
:issuable
)
{
issue
}
end
context
'when current_user cannot :admin_issue'
do
let
(
:visitor
)
{
create
(
:user
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
visitor
)
}
...
...
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