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
31f207b0
Commit
31f207b0
authored
Dec 23, 2021
by
Kev
Committed by
Rémy Coutable
Dec 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix RSpec/TimecopFreeze offenses (Part 2/2)
parent
3b815509
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
29 deletions
+26
-29
.rubocop_todo/rspec/timecop_freeze.yml
.rubocop_todo/rspec/timecop_freeze.yml
+0
-3
ee/spec/lib/gitlab/geo/git_push_http_spec.rb
ee/spec/lib/gitlab/geo/git_push_http_spec.rb
+6
-8
ee/spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
ee/spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
+10
-14
ee/spec/lib/gitlab/geo/oauth/login_state_spec.rb
ee/spec/lib/gitlab/geo/oauth/login_state_spec.rb
+10
-4
No files found.
.rubocop_todo/rspec/timecop_freeze.yml
View file @
31f207b0
...
...
@@ -2,9 +2,6 @@
RSpec/TimecopFreeze
:
Exclude
:
-
ee/spec/lib/gitlab/analytics/cycle_analytics/data_collector_spec.rb
-
ee/spec/lib/gitlab/geo/git_push_http_spec.rb
-
ee/spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
-
ee/spec/lib/gitlab/geo/oauth/login_state_spec.rb
-
ee/spec/lib/gitlab/insights/reducers/count_per_period_reducer_spec.rb
-
ee/spec/models/merge_train_spec.rb
-
ee/spec/support/shared_contexts/lib/gitlab/insights/reducers/reducers_shared_contexts.rb
...
...
ee/spec/lib/gitlab/geo/git_push_http_spec.rb
View file @
31f207b0
...
...
@@ -24,14 +24,12 @@ RSpec.describe Gitlab::Geo::GitPushHttp, :geo, :use_clean_rails_memory_store_cac
end
it
'stores the ID with an expiration'
do
Timecop
.
freeze
do
subject
.
cache_referrer_node
(
secondary
.
id
)
Timecop
.
travel
(
described_class
::
EXPIRES_IN
+
20
.
seconds
)
do
value
=
Rails
.
cache
.
read
(
cache_key
)
expect
(
value
).
to
be_nil
end
end
subject
.
cache_referrer_node
(
secondary
.
id
)
travel_to
((
described_class
::
EXPIRES_IN
+
20
.
seconds
).
from_now
)
value
=
Rails
.
cache
.
read
(
cache_key
)
expect
(
value
).
to
be_nil
end
end
...
...
ee/spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
View file @
31f207b0
...
...
@@ -81,12 +81,10 @@ RSpec.describe Gitlab::Geo::LogCursor::Daemon, :clean_gitlab_redis_shared_state
is_expected
.
to
receive
(
:find_and_handle_events!
).
and_raise
(
'any error'
).
twice
Timecop
.
freeze
do
daemon
.
run_once!
daemon
.
run_once!
Timecop
.
travel
(
described_class
::
MAX_ERROR_DURATION
+
1
.
second
)
do
daemon
.
run_once!
end
travel_to
((
described_class
::
MAX_ERROR_DURATION
+
1
.
second
).
from_now
)
do
daemon
.
run_once!
end
end
end
...
...
@@ -95,17 +93,15 @@ RSpec.describe Gitlab::Geo::LogCursor::Daemon, :clean_gitlab_redis_shared_state
it
'does not call `#exit!`'
do
is_expected
.
not_to
receive
(
:exit!
)
Timecop
.
freeze
do
is_expected
.
to
receive
(
:find_and_handle_events!
).
and_raise
(
'any error'
)
daemon
.
run_once!
is_expected
.
to
receive
(
:find_and_handle_events!
).
and_raise
(
'any error'
)
daemon
.
run_once!
Timecop
.
travel
(
described_class
::
MAX_ERROR_DURATION
+
1
.
second
)
do
is_expected
.
to
receive
(
:find_and_handle_events!
)
# successful
daemon
.
run_once!
travel_to
((
described_class
::
MAX_ERROR_DURATION
+
1
.
second
).
from_now
)
do
is_expected
.
to
receive
(
:find_and_handle_events!
)
# successful
daemon
.
run_once!
is_expected
.
to
receive
(
:find_and_handle_events!
).
and_raise
(
'any error'
)
daemon
.
run_once!
end
is_expected
.
to
receive
(
:find_and_handle_events!
).
and_raise
(
'any error'
)
daemon
.
run_once!
end
end
end
...
...
ee/spec/lib/gitlab/geo/oauth/login_state_spec.rb
View file @
31f207b0
...
...
@@ -9,7 +9,11 @@ RSpec.describe Gitlab::Geo::Oauth::LoginState do
let
(
:timestamp
)
{
Time
.
utc
(
2019
,
2
,
10
,
19
,
0
,
0
)
}
around
do
|
example
|
Timecop
.
freeze
(
timestamp
)
{
example
.
run
}
if
example
.
metadata
[
:no_traveling
]
example
.
run
else
travel_to
(
timestamp
)
{
example
.
run
}
end
end
before
do
...
...
@@ -68,12 +72,14 @@ RSpec.describe Gitlab::Geo::Oauth::LoginState do
expect
(
subject
.
valid?
).
to
eq
(
false
)
end
it
"returns false when token's expired"
do
subject
=
described_class
.
new
(
return_to:
return_to
,
salt:
salt
,
token:
token
)
it
"returns false when token's expired"
,
:no_traveling
do
subject
=
travel_to
(
timestamp
)
do
described_class
.
new
(
return_to:
return_to
,
salt:
salt
,
token:
token
)
end
# Needs to be at least 120 seconds, because the default expiry is
# 60 seconds with an additional 60 second leeway.
Timecop
.
freeze
(
timestamp
+
125
)
do
travel_to
(
timestamp
+
125
)
do
expect
(
subject
.
valid?
).
to
eq
(
false
)
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