BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
f3e8b888
Commit
f3e8b888
authored
Aug 19, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use travel_to instead of dependency injection, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5734#note_14056642
parent
ec4549e4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
12 deletions
+10
-12
pipeline.rb
app/models/ci/pipeline.rb
+2
-2
statuseable.rb
app/models/concerns/statuseable.rb
+1
-1
utils.rb
lib/gitlab/utils.rb
+0
-5
pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+6
-4
spec_helper.rb
spec/spec_helper.rb
+1
-0
No files found.
app/models/ci/pipeline.rb
View file @
f3e8b888
...
...
@@ -48,11 +48,11 @@ module Ci
end
before_transition
[
:created
,
:pending
]
=>
:running
do
|
pipeline
|
pipeline
.
started_at
=
Gitlab
::
Utils
.
now
pipeline
.
started_at
=
Time
.
now
end
before_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
pipeline
|
pipeline
.
finished_at
=
Gitlab
::
Utils
.
now
pipeline
.
finished_at
=
Time
.
now
end
before_transition
do
|
pipeline
|
...
...
app/models/concerns/statuseable.rb
View file @
f3e8b888
...
...
@@ -87,7 +87,7 @@ module Statuseable
if
started_at
&&
finished_at
finished_at
-
started_at
elsif
started_at
Gitlab
::
Utils
.
now
-
started_at
Time
.
now
-
started_at
end
end
end
lib/gitlab/utils.rb
View file @
f3e8b888
...
...
@@ -13,10 +13,5 @@ module Gitlab
def
force_utf8
(
str
)
str
.
force_encoding
(
Encoding
::
UTF_8
)
end
# The same as Time.now but using this would make it easier to test
def
now
Time
.
now
end
end
end
spec/models/ci/pipeline_spec.rb
View file @
f3e8b888
...
...
@@ -128,11 +128,13 @@ describe Ci::Pipeline, models: true do
describe
'#duration'
do
before
do
allow
(
Gitlab
::
Utils
).
to
receive
(
:now
).
and_return
(
current
-
120
,
current
)
travel_to
(
current
-
120
)
do
pipeline
.
run
end
pipeline
.
run
pipeline
.
succeed
travel_to
(
current
)
do
pipeline
.
succeed
end
end
it
'matches sum of builds duration'
do
...
...
spec/spec_helper.rb
View file @
f3e8b888
...
...
@@ -33,6 +33,7 @@ RSpec.configure do |config|
config
.
include
EmailHelpers
config
.
include
TestEnv
config
.
include
ActiveJob
::
TestHelper
config
.
include
ActiveSupport
::
Testing
::
TimeHelpers
config
.
include
StubGitlabCalls
config
.
include
StubGitlabData
...
...
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