Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
projects.thm.de
GitLab
Commits
9c49fa2d
Commit
9c49fa2d
authored
Nov 24, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix for builds with no start date and spec
parent
afe90d52
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletion
+32
-1
app/serializers/entity_date_helper.rb
app/serializers/entity_date_helper.rb
+2
-0
spec/serializers/analytics_build_entity_spec.rb
spec/serializers/analytics_build_entity_spec.rb
+30
-1
No files found.
app/serializers/entity_date_helper.rb
View file @
9c49fa2d
...
...
@@ -2,6 +2,8 @@ module EntityDateHelper
include
ActionView
::
Helpers
::
DateHelper
def
interval_in_words
(
diff
)
return
'not started'
unless
diff
"
#{
distance_of_time_in_words
(
Time
.
now
,
diff
)
}
ago"
end
...
...
spec/serializers/analytics_build_entity_spec.rb
View file @
9c49fa2d
...
...
@@ -7,7 +7,9 @@
context
'build with an author'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:build
)
{
create
(
:ci_build
,
author:
user
,
started_at:
2
.
hours
.
ago
,
finished_at:
1
.
hour
.
ago
)
}
let
(
:started_at
)
{
2
.
hours
.
ago
}
let
(
:finished_at
)
{
1
.
hour
.
ago
}
let
(
:build
)
{
create
(
:ci_build
,
author:
user
,
started_at:
started_at
,
finished_at:
finished_at
)
}
subject
{
entity
.
as_json
}
...
...
@@ -31,5 +33,32 @@
it
'contains the duration'
do
expect
(
subject
[
:total_time
]).
to
eq
(
hours:
1
)
end
context
'no started at or finished at date'
do
let
(
:started_at
)
{
nil
}
let
(
:finished_at
)
{
nil
}
it
'does not blow up'
do
expect
{
subject
[
:date
]
}.
not_to
raise_error
end
it
''
end
context
'no started at date'
do
let
(
:started_at
)
{
nil
}
it
'does not blow up'
do
expect
{
subject
[
:date
]
}.
not_to
raise_error
end
end
context
'no finished at date'
do
let
(
:finished_at
)
{
nil
}
it
'does not blow up'
do
expect
{
subject
[
:date
]
}.
not_to
raise_error
end
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