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
f340eb14
Commit
f340eb14
authored
Sep 18, 2020
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update guideline for time-sensitive tests
Recommend using ActiveSupport::Testing::TimeHelpers
parent
8d7c7f17
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
5 deletions
+4
-5
doc/development/testing_guide/best_practices.md
doc/development/testing_guide/best_practices.md
+4
-5
No files found.
doc/development/testing_guide/best_practices.md
View file @
f340eb14
...
...
@@ -497,10 +497,9 @@ let_it_be(:project, refind: true) { create(:project) }
### Time-sensitive tests
[
Timecop
](
https://github.com/travisjeffery/timecop
)
is available in our
Ruby-based tests for verifying things that are time-sensitive. Any test that
exercises or verifies something time-sensitive should make use of Timecop to
prevent transient test failures.
[
`ActiveSupport::Testing::TimeHelpers`
](
https://api.rubyonrails.org/v6.0.3.1/classes/ActiveSupport/Testing/TimeHelpers.html
)
can be used to verify things that are time-sensitive. Any test that exercises or verifies something time-sensitive
should make use of these helpers to prevent transient test failures.
Example:
...
...
@@ -508,7 +507,7 @@ Example:
it
'is overdue'
do
issue
=
build
(
:issue
,
due_date:
Date
.
tomorrow
)
Timecop
.
freeze
(
3
.
days
.
from_now
)
do
travel_to
(
3
.
days
.
from_now
)
do
expect
(
issue
).
to
be_overdue
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