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
a45fa017
Commit
a45fa017
authored
Nov 10, 2016
by
Ruben Davila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more specs and handle errors related to time parsing.
parent
fcd3625c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
app/services/slash_commands/interpret_service.rb
app/services/slash_commands/interpret_service.rb
+2
-2
spec/services/slash_commands/interpret_service_spec.rb
spec/services/slash_commands/interpret_service_spec.rb
+20
-0
No files found.
app/services/slash_commands/interpret_service.rb
View file @
a45fa017
...
...
@@ -254,7 +254,7 @@ module SlashCommands
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
end
command
:estimate
do
|
raw_duration
|
time_spent
=
ChronicDuration
.
parse
(
raw_duration
,
default_unit:
'hours'
)
time_spent
=
ChronicDuration
.
parse
(
raw_duration
,
default_unit:
'hours'
)
rescue
nil
if
time_spent
@updates
[
:time_estimate
]
=
time_spent
...
...
@@ -268,7 +268,7 @@ module SlashCommands
end
command
:spend
do
|
raw_duration
|
reduce_time
=
raw_duration
.
sub!
(
/\A-/
,
''
)
time_spent
=
ChronicDuration
.
parse
(
raw_duration
,
default_unit:
'hours'
)
time_spent
=
ChronicDuration
.
parse
(
raw_duration
,
default_unit:
'hours'
)
rescue
nil
if
time_spent
@updates
[
:spend_time
]
=
reduce_time
?
(
time_spent
*
-
1
)
:
time_spent
...
...
spec/services/slash_commands/interpret_service_spec.rb
View file @
a45fa017
...
...
@@ -472,11 +472,31 @@ describe SlashCommands::InterpretService, services: true do
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'empty command'
do
let
(
:content
)
{
'/estimate'
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'empty command'
do
let
(
:content
)
{
'/estimate abc'
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'spend command'
do
let
(
:content
)
{
'/spend 1h'
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'empty command'
do
let
(
:content
)
{
'/spend'
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'empty command'
do
let
(
:content
)
{
'/spend abc'
}
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