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
e8d1aefe
Commit
e8d1aefe
authored
Aug 24, 2020
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add timezone information to the reviewer roulette
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
42b06da0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
37 deletions
+26
-37
danger/roulette/Dangerfile
danger/roulette/Dangerfile
+1
-1
lib/gitlab/danger/teammate.rb
lib/gitlab/danger/teammate.rb
+1
-3
spec/lib/gitlab/danger/teammate_spec.rb
spec/lib/gitlab/danger/teammate_spec.rb
+24
-33
No files found.
danger/roulette/Dangerfile
View file @
e8d1aefe
...
...
@@ -56,7 +56,7 @@ def note_for_spin_role(spin, role)
return
OPTIONAL_REVIEW_TEMPLATE
%
{
role:
role
.
capitalize
,
category:
helper
.
label_for_category
(
spin
.
category
)
}
end
spin
.
public_send
(
role
)
&
.
markdown_name
(
timezone_experiment:
spin
.
timezone_experiment
,
author:
roulette
.
team_mr_author
)
# rubocop:disable GitlabSecurity/PublicSend
spin
.
public_send
(
role
)
&
.
markdown_name
(
author:
roulette
.
team_mr_author
)
# rubocop:disable GitlabSecurity/PublicSend
end
def
markdown_row_for_spins
(
category
,
spins_array
)
...
...
lib/gitlab/danger/teammate.rb
View file @
e8d1aefe
...
...
@@ -45,9 +45,7 @@ module Gitlab
has_capability?
(
project
,
category
,
:maintainer
,
labels
)
end
def
markdown_name
(
timezone_experiment:
false
,
author:
nil
)
return
@markdown_name
unless
timezone_experiment
def
markdown_name
(
author:
nil
)
"
#{
@markdown_name
}
(
#{
utc_offset_text
(
author
)
}
)"
end
...
...
spec/lib/gitlab/danger/teammate_spec.rb
View file @
e8d1aefe
...
...
@@ -170,47 +170,38 @@ RSpec.describe Gitlab::Danger::Teammate do
end
describe
'#markdown_name'
do
context
'when timezone_experiment == false'
do
it
'returns markdown name as-is'
do
expect
(
subject
.
markdown_name
).
to
eq
(
options
[
'markdown_name'
])
expect
(
subject
.
markdown_name
(
timezone_experiment:
false
)).
to
eq
(
options
[
'markdown_name'
])
end
it
'returns markdown name with timezone info'
do
expect
(
subject
.
markdown_name
).
to
eq
(
"
#{
options
[
'markdown_name'
]
}
(UTC+2)"
)
end
context
'when timezone_experiment == true'
do
it
'returns markdown name with timezone info'
do
expect
(
subject
.
markdown_name
(
timezone_experiment:
true
)).
to
eq
(
"
#{
options
[
'markdown_name'
]
}
(UTC+2)"
)
end
context
'when offset is 1.5'
do
let
(
:tz_offset_hours
)
{
1.5
}
context
'when offset is 1.5'
do
let
(
:tz_offset_hours
)
{
1.5
}
it
'returns markdown name with timezone info, not truncated'
do
expect
(
subject
.
markdown_name
(
timezone_experiment:
true
)).
to
eq
(
"
#{
options
[
'markdown_name'
]
}
(UTC+1.5)"
)
end
it
'returns markdown name with timezone info, not truncated'
do
expect
(
subject
.
markdown_name
).
to
eq
(
"
#{
options
[
'markdown_name'
]
}
(UTC+1.5)"
)
end
end
context
'when author is given'
do
where
(
:tz_offset_hours
,
:author_offset
,
:diff_text
)
do
-
12
|
-
10
|
"2 hours behind `@mario`"
-
10
|
-
12
|
"2 hours ahead of `@mario`"
-
10
|
2
|
"12 hours behind `@mario`"
2
|
4
|
"2 hours behind `@mario`"
4
|
2
|
"2 hours ahead of `@mario`"
2
|
3
|
"1 hour behind `@mario`"
3
|
2
|
"1 hour ahead of `@mario`"
2
|
2
|
"same timezone as `@mario`"
end
context
'when author is given'
do
where
(
:tz_offset_hours
,
:author_offset
,
:diff_text
)
do
-
12
|
-
10
|
"2 hours behind `@mario`"
-
10
|
-
12
|
"2 hours ahead of `@mario`"
-
10
|
2
|
"12 hours behind `@mario`"
2
|
4
|
"2 hours behind `@mario`"
4
|
2
|
"2 hours ahead of `@mario`"
2
|
3
|
"1 hour behind `@mario`"
3
|
2
|
"1 hour ahead of `@mario`"
2
|
2
|
"same timezone as `@mario`"
end
with_them
do
it
'returns markdown name with timezone info'
do
author
=
described_class
.
new
(
options
.
merge
(
'username'
=>
'mario'
,
'tz_offset_hours'
=>
author_offset
))
with_them
do
it
'returns markdown name with timezone info'
do
author
=
described_class
.
new
(
options
.
merge
(
'username'
=>
'mario'
,
'tz_offset_hours'
=>
author_offset
))
floored_offset_hours
=
subject
.
__send__
(
:floored_offset_hours
)
utc_offset
=
floored_offset_hours
>=
0
?
"+
#{
floored_offset_hours
}
"
:
floored_offset_hours
floored_offset_hours
=
subject
.
__send__
(
:floored_offset_hours
)
utc_offset
=
floored_offset_hours
>=
0
?
"+
#{
floored_offset_hours
}
"
:
floored_offset_hours
expect
(
subject
.
markdown_name
(
timezone_experiment:
true
,
author:
author
)).
to
eq
(
"
#{
options
[
'markdown_name'
]
}
(UTC
#{
utc_offset
}
,
#{
diff_text
}
)"
)
end
expect
(
subject
.
markdown_name
(
author:
author
)).
to
eq
(
"
#{
options
[
'markdown_name'
]
}
(UTC
#{
utc_offset
}
,
#{
diff_text
}
)"
)
end
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