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
45b9bc34
Commit
45b9bc34
authored
Sep 06, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
5d9f5e82
913c87c6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
0 deletions
+79
-0
changelogs/unreleased/59729-estimate-quick-action-does-not-produce-correct-time-for-1mo.yml
...te-quick-action-does-not-produce-correct-time-for-1mo.yml
+5
-0
config/initializers/chronic_duration.rb
config/initializers/chronic_duration.rb
+4
-0
lib/gitlab/patch/chronic_duration.rb
lib/gitlab/patch/chronic_duration.rb
+35
-0
spec/lib/gitlab/patch/chronic_duration_spec.rb
spec/lib/gitlab/patch/chronic_duration_spec.rb
+27
-0
spec/lib/gitlab/time_tracking_formatter_spec.rb
spec/lib/gitlab/time_tracking_formatter_spec.rb
+8
-0
No files found.
changelogs/unreleased/59729-estimate-quick-action-does-not-produce-correct-time-for-1mo.yml
0 → 100644
View file @
45b9bc34
---
title
:
Fix parsing of months in time tracking commands
merge_request
:
32165
author
:
type
:
fixed
config/initializers/chronic_duration.rb
View file @
45b9bc34
# frozen_string_literal: true
ChronicDuration
.
raise_exceptions
=
true
ChronicDuration
.
prepend
Gitlab
::
Patch
::
ChronicDuration
lib/gitlab/patch/chronic_duration.rb
0 → 100644
View file @
45b9bc34
# frozen_string_literal: true
# Fixes a bug where parsing months doesn't take into account
# the ChronicDuration.days_per_week setting
#
# We can remove this when we do a refactor and push upstream in
# https://gitlab.com/gitlab-org/gitlab-ce/issues/66637
module
Gitlab
module
Patch
module
ChronicDuration
extend
ActiveSupport
::
Concern
class_methods
do
def
duration_units_seconds_multiplier
(
unit
)
return
0
unless
duration_units_list
.
include?
(
unit
)
case
unit
when
'months'
3600
*
::
ChronicDuration
.
hours_per_day
*
::
ChronicDuration
.
days_per_month
else
super
end
end
# ChronicDuration#output uses 1mo = 4w as the conversion so we do the same here.
# We do need to add a special case for the default days_per_week value because
# we want to retain existing behavior for the default case
def
days_per_month
::
ChronicDuration
.
days_per_week
==
7
?
30
:
::
ChronicDuration
.
days_per_week
*
4
end
end
end
end
end
spec/lib/gitlab/patch/chronic_duration_spec.rb
0 → 100644
View file @
45b9bc34
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
Patch
::
ChronicDuration
do
subject
{
ChronicDuration
.
parse
(
'1mo'
)
}
it
'uses default conversions'
do
expect
(
subject
).
to
eq
(
2_592_000
)
end
context
'with custom conversions'
do
before
do
ChronicDuration
.
hours_per_day
=
8
ChronicDuration
.
days_per_week
=
5
end
after
do
ChronicDuration
.
hours_per_day
=
24
ChronicDuration
.
days_per_week
=
7
end
it
'uses custom conversions'
do
expect
(
subject
).
to
eq
(
576_000
)
end
end
end
spec/lib/gitlab/time_tracking_formatter_spec.rb
View file @
45b9bc34
...
...
@@ -17,6 +17,14 @@ describe Gitlab::TimeTrackingFormatter do
it
{
expect
(
subject
).
to
eq
(
-
12_000
)
}
end
context
'durations with months'
do
let
(
:duration_string
)
{
'1mo'
}
it
'uses our custom conversions'
do
expect
(
subject
).
to
eq
(
576_000
)
end
end
end
describe
'#output'
do
...
...
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