Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
7a8d2164
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7a8d2164
编写于
8月 24, 2019
作者:
H
Heinrich Lee Yu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix time tracking parsing of months
Patches ChronicDuration to use our custom conversions when parsing months
上级
dd80d622
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
79 addition
and
0 deletion
+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
未找到文件。
changelogs/unreleased/59729-estimate-quick-action-does-not-produce-correct-time-for-1mo.yml
0 → 100644
浏览文件 @
7a8d2164
---
title
:
Fix parsing of months in time tracking commands
merge_request
:
32165
author
:
type
:
fixed
config/initializers/chronic_duration.rb
浏览文件 @
7a8d2164
# frozen_string_literal: true
ChronicDuration
.
raise_exceptions
=
true
ChronicDuration
.
prepend
Gitlab
::
Patch
::
ChronicDuration
lib/gitlab/patch/chronic_duration.rb
0 → 100644
浏览文件 @
7a8d2164
# 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
浏览文件 @
7a8d2164
# 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
浏览文件 @
7a8d2164
...
...
@@ -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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录