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
Show 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 @@
...
@@ -2,9 +2,6 @@
RSpec/TimecopFreeze
:
RSpec/TimecopFreeze
:
Exclude
:
Exclude
:
-
ee/spec/lib/gitlab/analytics/cycle_analytics/data_collector_spec.rb
-
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/lib/gitlab/insights/reducers/count_per_period_reducer_spec.rb
-
ee/spec/models/merge_train_spec.rb
-
ee/spec/models/merge_train_spec.rb
-
ee/spec/support/shared_contexts/lib/gitlab/insights/reducers/reducers_shared_contexts.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,16 +24,14 @@ RSpec.describe Gitlab::Geo::GitPushHttp, :geo, :use_clean_rails_memory_store_cac
...
@@ -24,16 +24,14 @@ RSpec.describe Gitlab::Geo::GitPushHttp, :geo, :use_clean_rails_memory_store_cac
end
end
it
'stores the ID with an expiration'
do
it
'stores the ID with an expiration'
do
Timecop
.
freeze
do
subject
.
cache_referrer_node
(
secondary
.
id
)
subject
.
cache_referrer_node
(
secondary
.
id
)
Timecop
.
travel
(
described_class
::
EXPIRES_IN
+
20
.
seconds
)
do
travel_to
((
described_class
::
EXPIRES_IN
+
20
.
seconds
).
from_now
)
value
=
Rails
.
cache
.
read
(
cache_key
)
value
=
Rails
.
cache
.
read
(
cache_key
)
expect
(
value
).
to
be_nil
expect
(
value
).
to
be_nil
end
end
end
end
end
end
context
'when geo_node_id is not an integer'
do
context
'when geo_node_id is not an integer'
do
it
'does not cache anything'
do
it
'does not cache anything'
do
...
...
ee/spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
View file @
31f207b0
...
@@ -81,25 +81,22 @@ RSpec.describe Gitlab::Geo::LogCursor::Daemon, :clean_gitlab_redis_shared_state
...
@@ -81,25 +81,22 @@ RSpec.describe Gitlab::Geo::LogCursor::Daemon, :clean_gitlab_redis_shared_state
is_expected
.
to
receive
(
:find_and_handle_events!
).
and_raise
(
'any error'
).
twice
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
travel_to
((
described_class
::
MAX_ERROR_DURATION
+
1
.
second
).
from_now
)
do
daemon
.
run_once!
daemon
.
run_once!
end
end
end
end
end
end
end
context
'when this error is not the final straw'
do
context
'when this error is not the final straw'
do
it
'does not call `#exit!`'
do
it
'does not call `#exit!`'
do
is_expected
.
not_to
receive
(
:exit!
)
is_expected
.
not_to
receive
(
:exit!
)
Timecop
.
freeze
do
is_expected
.
to
receive
(
:find_and_handle_events!
).
and_raise
(
'any error'
)
is_expected
.
to
receive
(
:find_and_handle_events!
).
and_raise
(
'any error'
)
daemon
.
run_once!
daemon
.
run_once!
Timecop
.
travel
(
described_class
::
MAX_ERROR_DURATION
+
1
.
second
)
do
travel_to
((
described_class
::
MAX_ERROR_DURATION
+
1
.
second
).
from_now
)
do
is_expected
.
to
receive
(
:find_and_handle_events!
)
# successful
is_expected
.
to
receive
(
:find_and_handle_events!
)
# successful
daemon
.
run_once!
daemon
.
run_once!
...
@@ -110,7 +107,6 @@ RSpec.describe Gitlab::Geo::LogCursor::Daemon, :clean_gitlab_redis_shared_state
...
@@ -110,7 +107,6 @@ RSpec.describe Gitlab::Geo::LogCursor::Daemon, :clean_gitlab_redis_shared_state
end
end
end
end
end
end
end
describe
'#find_and_handle_events!'
do
describe
'#find_and_handle_events!'
do
context
'with some event logs'
do
context
'with some event logs'
do
...
...
ee/spec/lib/gitlab/geo/oauth/login_state_spec.rb
View file @
31f207b0
...
@@ -9,7 +9,11 @@ RSpec.describe Gitlab::Geo::Oauth::LoginState do
...
@@ -9,7 +9,11 @@ RSpec.describe Gitlab::Geo::Oauth::LoginState do
let
(
:timestamp
)
{
Time
.
utc
(
2019
,
2
,
10
,
19
,
0
,
0
)
}
let
(
:timestamp
)
{
Time
.
utc
(
2019
,
2
,
10
,
19
,
0
,
0
)
}
around
do
|
example
|
around
do
|
example
|
Timecop
.
freeze
(
timestamp
)
{
example
.
run
}
if
example
.
metadata
[
:no_traveling
]
example
.
run
else
travel_to
(
timestamp
)
{
example
.
run
}
end
end
end
before
do
before
do
...
@@ -68,12 +72,14 @@ RSpec.describe Gitlab::Geo::Oauth::LoginState do
...
@@ -68,12 +72,14 @@ RSpec.describe Gitlab::Geo::Oauth::LoginState do
expect
(
subject
.
valid?
).
to
eq
(
false
)
expect
(
subject
.
valid?
).
to
eq
(
false
)
end
end
it
"returns false when token's expired"
do
it
"returns false when token's expired"
,
:no_traveling
do
subject
=
described_class
.
new
(
return_to:
return_to
,
salt:
salt
,
token:
token
)
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
# Needs to be at least 120 seconds, because the default expiry is
# 60 seconds with an additional 60 second leeway.
# 60 seconds with an additional 60 second leeway.
Timecop
.
freeze
(
timestamp
+
125
)
do
travel_to
(
timestamp
+
125
)
do
expect
(
subject
.
valid?
).
to
eq
(
false
)
expect
(
subject
.
valid?
).
to
eq
(
false
)
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