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
276d70ae
Commit
276d70ae
authored
Apr 03, 2021
by
Lee Tickett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add /spent quick action alias
parent
1e54f727
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
14 deletions
+79
-14
changelogs/unreleased/20235-add-spent-quick-action-alias.yml
changelogs/unreleased/20235-add-spent-quick-action-alias.yml
+5
-0
lib/gitlab/quick_actions/issue_and_merge_request_actions.rb
lib/gitlab/quick_actions/issue_and_merge_request_actions.rb
+1
-1
lib/gitlab/usage_data_counters/quick_action_activity_unique_counter.rb
...age_data_counters/quick_action_activity_unique_counter.rb
+1
-1
spec/lib/gitlab/usage_data_counters/quick_action_activity_unique_counter_spec.rb
...ata_counters/quick_action_activity_unique_counter_spec.rb
+20
-0
spec/services/quick_actions/interpret_service_spec.rb
spec/services/quick_actions/interpret_service_spec.rb
+52
-12
No files found.
changelogs/unreleased/20235-add-spent-quick-action-alias.yml
0 → 100644
View file @
276d70ae
---
title
:
Add spent quick action alias
merge_request
:
58539
author
:
Lee Tickett @leetickett
type
:
added
lib/gitlab/quick_actions/issue_and_merge_request_actions.rb
View file @
276d70ae
...
@@ -182,7 +182,7 @@ module Gitlab
...
@@ -182,7 +182,7 @@ module Gitlab
parse_params
do
|
raw_time_date
|
parse_params
do
|
raw_time_date
|
Gitlab
::
QuickActions
::
SpendTimeAndDateSeparator
.
new
(
raw_time_date
).
execute
Gitlab
::
QuickActions
::
SpendTimeAndDateSeparator
.
new
(
raw_time_date
).
execute
end
end
command
:spend
do
|
time_spent
,
time_spent_date
|
command
:spend
,
:spent
do
|
time_spent
,
time_spent_date
|
if
time_spent
if
time_spent
@updates
[
:spend_time
]
=
{
@updates
[
:spend_time
]
=
{
duration:
time_spent
,
duration:
time_spent
,
...
...
lib/gitlab/usage_data_counters/quick_action_activity_unique_counter.rb
View file @
276d70ae
...
@@ -28,7 +28,7 @@ module Gitlab
...
@@ -28,7 +28,7 @@ module Gitlab
'unassign_reviewer'
'unassign_reviewer'
when
'request_review'
,
'reviewer'
when
'request_review'
,
'reviewer'
'assign_reviewer'
'assign_reviewer'
when
'spend'
when
'spend'
,
'spent'
event_name_for_spend
(
args
)
event_name_for_spend
(
args
)
when
'unassign'
when
'unassign'
event_name_for_unassign
(
args
)
event_name_for_unassign
(
args
)
...
...
spec/lib/gitlab/usage_data_counters/quick_action_activity_unique_counter_spec.rb
View file @
276d70ae
...
@@ -115,6 +115,26 @@ RSpec.describe Gitlab::UsageDataCounters::QuickActionActivityUniqueCounter, :cle
...
@@ -115,6 +115,26 @@ RSpec.describe Gitlab::UsageDataCounters::QuickActionActivityUniqueCounter, :cle
end
end
end
end
context
'tracking spent'
do
let
(
:quickaction_name
)
{
'spent'
}
context
'adding time'
do
let
(
:args
)
{
'1d'
}
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_spend_add'
}
end
end
context
'removing time'
do
let
(
:args
)
{
'-1d'
}
it_behaves_like
'a tracked quick action unique event'
do
let
(
:action
)
{
'i_quickactions_spend_subtract'
}
end
end
end
context
'tracking unassign'
do
context
'tracking unassign'
do
let
(
:quickaction_name
)
{
'unassign'
}
let
(
:quickaction_name
)
{
'unassign'
}
...
...
spec/services/quick_actions/interpret_service_spec.rb
View file @
276d70ae
...
@@ -368,24 +368,24 @@ RSpec.describe QuickActions::InterpretService do
...
@@ -368,24 +368,24 @@ RSpec.describe QuickActions::InterpretService do
spent_at:
DateTime
.
current
.
to_date
spent_at:
DateTime
.
current
.
to_date
})
})
end
end
it
'returns the spend_time message including the formatted duration and verb'
do
_
,
_
,
message
=
service
.
execute
(
'/spend -120m'
,
issuable
)
expect
(
message
).
to
eq
(
'Subtracted 2h spent time.'
)
end
end
end
shared_examples
'spend command with negative time'
do
shared_examples
'spend command with negative time'
do
it
'populates spend_time: -
1800 if content contains /spend -3
0m'
do
it
'populates spend_time: -
7200 if content contains -12
0m'
do
_
,
updates
,
_
=
service
.
execute
(
content
,
issuable
)
_
,
updates
,
_
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
).
to
eq
(
spend_time:
{
expect
(
updates
).
to
eq
(
spend_time:
{
duration:
-
18
00
,
duration:
-
72
00
,
user_id:
developer
.
id
,
user_id:
developer
.
id
,
spent_at:
DateTime
.
current
.
to_date
spent_at:
DateTime
.
current
.
to_date
})
})
end
end
it
'returns the spend_time message including the formatted duration and verb'
do
_
,
_
,
message
=
service
.
execute
(
content
,
issuable
)
expect
(
message
).
to
eq
(
'Subtracted 2h spent time.'
)
end
end
end
shared_examples
'spend command with valid date'
do
shared_examples
'spend command with valid date'
do
...
@@ -1242,8 +1242,18 @@ RSpec.describe QuickActions::InterpretService do
...
@@ -1242,8 +1242,18 @@ RSpec.describe QuickActions::InterpretService do
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
it_behaves_like
'spend command'
do
let
(
:content
)
{
'/spent 1h'
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'spend command with negative time'
do
it_behaves_like
'spend command with negative time'
do
let
(
:content
)
{
'/spend -30m'
}
let
(
:content
)
{
'/spend -120m'
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'spend command with negative time'
do
let
(
:content
)
{
'/spent -120m'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
...
@@ -1253,26 +1263,52 @@ RSpec.describe QuickActions::InterpretService do
...
@@ -1253,26 +1263,52 @@ RSpec.describe QuickActions::InterpretService do
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
it_behaves_like
'spend command with valid date'
do
let
(
:date
)
{
'2016-02-02'
}
let
(
:content
)
{
"/spent 30m
#{
date
}
"
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'spend command with invalid date'
do
it_behaves_like
'spend command with invalid date'
do
let
(
:content
)
{
'/spend 30m 17-99-99'
}
let
(
:content
)
{
'/spend 30m 17-99-99'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
it_behaves_like
'spend command with invalid date'
do
let
(
:content
)
{
'/spent 30m 17-99-99'
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'spend command with future date'
do
it_behaves_like
'spend command with future date'
do
let
(
:content
)
{
'/spend 30m 6017-10-10'
}
let
(
:content
)
{
'/spend 30m 6017-10-10'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
it_behaves_like
'spend command with future date'
do
let
(
:content
)
{
'/spent 30m 6017-10-10'
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'failed command'
do
it_behaves_like
'failed command'
do
let
(
:content
)
{
'/spend'
}
let
(
:content
)
{
'/spend'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
it_behaves_like
'failed command'
do
let
(
:content
)
{
'/spent'
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'failed command'
do
it_behaves_like
'failed command'
do
let
(
:content
)
{
'/spend abc'
}
let
(
:content
)
{
'/spend abc'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
it_behaves_like
'failed command'
do
let
(
:content
)
{
'/spent abc'
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'remove_estimate command'
do
it_behaves_like
'remove_estimate command'
do
let
(
:content
)
{
'/remove_estimate'
}
let
(
:content
)
{
'/remove_estimate'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
...
@@ -2247,10 +2283,14 @@ RSpec.describe QuickActions::InterpretService do
...
@@ -2247,10 +2283,14 @@ RSpec.describe QuickActions::InterpretService do
end
end
describe
'spend command'
do
describe
'spend command'
do
let
(
:content
)
{
'/spend -120m'
}
it
'includes the formatted duration and proper verb when using /spend'
do
_
,
explanations
=
service
.
explain
(
'/spend -120m'
,
issue
)
it
'includes the formatted duration and proper verb'
do
expect
(
explanations
).
to
eq
([
'Subtracts 2h spent time.'
])
_
,
explanations
=
service
.
explain
(
content
,
issue
)
end
it
'includes the formatted duration and proper verb when using /spent'
do
_
,
explanations
=
service
.
explain
(
'/spent -120m'
,
issue
)
expect
(
explanations
).
to
eq
([
'Subtracts 2h spent time.'
])
expect
(
explanations
).
to
eq
([
'Subtracts 2h spent time.'
])
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