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
19bce20e
Commit
19bce20e
authored
Jul 08, 2020
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pluralize hours in Teammate::Danger
parent
de284cbc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
lib/gitlab/danger/teammate.rb
lib/gitlab/danger/teammate.rb
+8
-1
spec/lib/gitlab/danger/teammate_spec.rb
spec/lib/gitlab/danger/teammate_spec.rb
+2
-0
No files found.
lib/gitlab/danger/teammate.rb
View file @
19bce20e
...
...
@@ -72,8 +72,9 @@ module Gitlab
return
"same timezone as `@
#{
author
.
username
}
`"
if
diff
.
zero?
ahead_or_behind
=
diff
<
0
?
'behind'
:
'ahead'
pluralized_hours
=
pluralize
(
diff
.
abs
,
'hour'
,
'hours'
)
"
#{
diff
.
abs
}
hours
#{
ahead_or_behind
}
`@
#{
author
.
username
}
`"
"
#{
pluralized_hours
}
#{
ahead_or_behind
}
`@
#{
author
.
username
}
`"
end
def
has_capability?
(
project
,
category
,
kind
,
labels
)
...
...
@@ -95,6 +96,12 @@ module Gitlab
def
capabilities
(
project
)
Array
(
projects
.
fetch
(
project
,
[]))
end
def
pluralize
(
count
,
singular
,
plural
)
word
=
count
==
1
||
count
.
to_s
=~
/^1(\.0+)?$/
?
singular
:
plural
"
#{
count
||
0
}
#{
word
}
"
end
end
end
end
spec/lib/gitlab/danger/teammate_spec.rb
View file @
19bce20e
...
...
@@ -178,6 +178,8 @@ RSpec.describe Gitlab::Danger::Teammate do
-
10
|
2
|
"12 hours behind `@mario`"
2
|
4
|
"2 hours behind `@mario`"
4
|
2
|
"2 hours ahead `@mario`"
2
|
3
|
"1 hour behind `@mario`"
3
|
2
|
"1 hour ahead `@mario`"
2
|
2
|
"same timezone as `@mario`"
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