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
8f6bcd01
Commit
8f6bcd01
authored
Oct 13, 2020
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable RSpec/TimecopTravel cop
- Run autocorrection - Add failing specs to todo
parent
72e31fab
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
70 additions
and
47 deletions
+70
-47
.rubocop.yml
.rubocop.yml
+1
-1
.rubocop_todo.yml
.rubocop_todo.yml
+23
-0
ee/spec/frontend/fixtures/analytics.rb
ee/spec/frontend/fixtures/analytics.rb
+2
-2
ee/spec/lib/gitlab/analytics/cycle_analytics/data_collector_spec.rb
...b/gitlab/analytics/cycle_analytics/data_collector_spec.rb
+7
-7
ee/spec/lib/gitlab/analytics/cycle_analytics/request_params_spec.rb
...b/gitlab/analytics/cycle_analytics/request_params_spec.rb
+1
-1
ee/spec/lib/gitlab/geo/event_gap_tracking_spec.rb
ee/spec/lib/gitlab/geo/event_gap_tracking_spec.rb
+4
-4
ee/spec/lib/gitlab/geo/jwt_request_decoder_spec.rb
ee/spec/lib/gitlab/geo/jwt_request_decoder_spec.rb
+2
-2
ee/spec/models/ee/namespace/root_storage_size_spec.rb
ee/spec/models/ee/namespace/root_storage_size_spec.rb
+1
-1
ee/spec/models/gitlab/seat_link_data_spec.rb
ee/spec/models/gitlab/seat_link_data_spec.rb
+1
-1
ee/spec/requests/rack_attack_spec.rb
ee/spec/requests/rack_attack_spec.rb
+1
-1
ee/spec/support/shared_examples/controllers/analytics/cycle_analytics/shared_stage_shared_examples.rb
...analytics/cycle_analytics/shared_stage_shared_examples.rb
+1
-1
ee/spec/workers/sync_seat_link_worker_spec.rb
ee/spec/workers/sync_seat_link_worker_spec.rb
+3
-3
spec/features/admin/admin_mode/login_spec.rb
spec/features/admin/admin_mode/login_spec.rb
+5
-5
spec/features/dashboard/issuables_counter_spec.rb
spec/features/dashboard/issuables_counter_spec.rb
+2
-2
spec/lib/forever_spec.rb
spec/lib/forever_spec.rb
+1
-1
spec/lib/gitlab/auth/unique_ips_limiter_spec.rb
spec/lib/gitlab/auth/unique_ips_limiter_spec.rb
+1
-1
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+1
-1
spec/requests/api/ci/runner/jobs_put_spec.rb
spec/requests/api/ci/runner/jobs_put_spec.rb
+1
-1
spec/requests/rack_attack_global_spec.rb
spec/requests/rack_attack_global_spec.rb
+1
-1
spec/services/ci/pipeline_processing/shared_processing_service.rb
...vices/ci/pipeline_processing/shared_processing_service.rb
+5
-5
spec/services/deployments/update_environment_service_spec.rb
spec/services/deployments/update_environment_service_spec.rb
+1
-1
spec/support/helpers/usage_data_helpers.rb
spec/support/helpers/usage_data_helpers.rb
+1
-1
spec/support/shared_examples/requests/rack_attack_shared_examples.rb
...t/shared_examples/requests/rack_attack_shared_examples.rb
+2
-2
spec/support/shared_examples/services/boards/issues_move_service_shared_examples.rb
...es/services/boards/issues_move_service_shared_examples.rb
+1
-1
spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb
...rs/metrics/dashboard/prune_old_annotations_worker_spec.rb
+1
-1
No files found.
.rubocop.yml
View file @
8f6bcd01
...
@@ -301,7 +301,7 @@ RSpec/TimecopFreeze:
...
@@ -301,7 +301,7 @@ RSpec/TimecopFreeze:
-
'
qa/spec/**/*.rb'
-
'
qa/spec/**/*.rb'
RSpec/TimecopTravel
:
RSpec/TimecopTravel
:
Enabled
:
fals
e
Enabled
:
tru
e
AutoCorrect
:
true
AutoCorrect
:
true
Include
:
Include
:
-
'
spec/**/*.rb'
-
'
spec/**/*.rb'
...
...
.rubocop_todo.yml
View file @
8f6bcd01
...
@@ -1246,6 +1246,29 @@ RSpec/TimecopFreeze:
...
@@ -1246,6 +1246,29 @@ RSpec/TimecopFreeze:
-
'
spec/workers/concerns/reenqueuer_spec.rb'
-
'
spec/workers/concerns/reenqueuer_spec.rb'
-
'
spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb'
-
'
spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb'
# Offense count: 54
# Cop supports --auto-correct.
RSpec/TimecopTravel
:
Exclude
:
-
'
ee/spec/lib/gitlab/geo/event_gap_tracking_spec.rb'
-
'
ee/spec/lib/gitlab/geo/git_push_http_spec.rb'
-
'
ee/spec/lib/gitlab/geo/jwt_request_decoder_spec.rb'
-
'
ee/spec/lib/gitlab/geo/log_cursor/daemon_spec.rb'
-
'
ee/spec/models/broadcast_message_spec.rb'
-
'
ee/spec/models/burndown_spec.rb'
-
'
qa/spec/support/repeater_spec.rb'
-
'
spec/features/users/terms_spec.rb'
-
'
spec/lib/feature_spec.rb'
-
'
spec/models/broadcast_message_spec.rb'
-
'
spec/models/concerns/issuable_spec.rb'
-
'
spec/requests/api/ci/runner/jobs_trace_spec.rb'
-
'
spec/requests/api/issues/put_projects_issues_spec.rb'
-
'
spec/support/shared_contexts/cache_allowed_users_in_namespace_shared_context.rb'
-
'
spec/support/shared_examples/requests/api/time_tracking_shared_examples.rb'
-
'
spec/support/shared_examples/workers/concerns/reenqueuer_shared_examples.rb'
-
'
spec/workers/concerns/reenqueuer_spec.rb'
-
'
spec/lib/gitlab/analytics/cycle_analytics/median_spec.rb'
# Offense count: 43
# Offense count: 43
Graphql/IDType
:
Graphql/IDType
:
Exclude
:
Exclude
:
...
...
ee/spec/frontend/fixtures/analytics.rb
View file @
8f6bcd01
...
@@ -98,7 +98,7 @@ RSpec.describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do
...
@@ -98,7 +98,7 @@ RSpec.describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do
issue
=
create
(
:issue
,
project:
project
,
created_at:
20
.
days
.
ago
,
author:
user
)
issue
=
create
(
:issue
,
project:
project
,
created_at:
20
.
days
.
ago
,
author:
user
)
Timecop
.
travel
(
5
.
days
.
ago
)
do
travel_to
(
5
.
days
.
ago
)
do
Issues
::
UpdateService
.
new
(
Issues
::
UpdateService
.
new
(
project
,
project
,
user
,
user
,
...
@@ -106,7 +106,7 @@ RSpec.describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do
...
@@ -106,7 +106,7 @@ RSpec.describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do
).
execute
(
issue
)
).
execute
(
issue
)
end
end
Timecop
.
travel
(
2
.
days
.
ago
)
do
travel_to
(
2
.
days
.
ago
)
do
Issues
::
UpdateService
.
new
(
Issues
::
UpdateService
.
new
(
project
,
project
,
user
,
user
,
...
...
ee/spec/lib/gitlab/analytics/cycle_analytics/data_collector_spec.rb
View file @
8f6bcd01
...
@@ -24,29 +24,29 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::DataCollector do
...
@@ -24,29 +24,29 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::DataCollector do
before
do
before
do
# takes 10 days
# takes 10 days
resource1
=
Timecop
.
travel
(
Time
.
new
(
2019
,
3
,
5
))
do
resource1
=
travel_to
(
Time
.
new
(
2019
,
3
,
5
))
do
create_data_for_start_event
(
self
)
create_data_for_start_event
(
self
)
end
end
Timecop
.
travel
(
Time
.
new
(
2019
,
3
,
15
))
do
travel_to
(
Time
.
new
(
2019
,
3
,
15
))
do
create_data_for_end_event
(
resource1
,
self
)
create_data_for_end_event
(
resource1
,
self
)
end
end
# takes 5 days
# takes 5 days
resource2
=
Timecop
.
travel
(
Time
.
new
(
2019
,
3
,
5
))
do
resource2
=
travel_to
(
Time
.
new
(
2019
,
3
,
5
))
do
create_data_for_start_event
(
self
)
create_data_for_start_event
(
self
)
end
end
Timecop
.
travel
(
Time
.
new
(
2019
,
3
,
10
))
do
travel_to
(
Time
.
new
(
2019
,
3
,
10
))
do
create_data_for_end_event
(
resource2
,
self
)
create_data_for_end_event
(
resource2
,
self
)
end
end
# takes 15 days
# takes 15 days
resource3
=
Timecop
.
travel
(
Time
.
new
(
2019
,
3
,
5
))
do
resource3
=
travel_to
(
Time
.
new
(
2019
,
3
,
5
))
do
create_data_for_start_event
(
self
)
create_data_for_start_event
(
self
)
end
end
Timecop
.
travel
(
Time
.
new
(
2019
,
3
,
20
))
do
travel_to
(
Time
.
new
(
2019
,
3
,
20
))
do
create_data_for_end_event
(
resource3
,
self
)
create_data_for_end_event
(
resource3
,
self
)
end
end
end
end
...
@@ -478,7 +478,7 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::DataCollector do
...
@@ -478,7 +478,7 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::DataCollector do
before
do
before
do
group
.
add_user
(
user
,
GroupMember
::
MAINTAINER
)
group
.
add_user
(
user
,
GroupMember
::
MAINTAINER
)
Timecop
.
travel
(
Time
.
new
(
2019
,
6
,
1
))
do
travel_to
(
Time
.
new
(
2019
,
6
,
1
))
do
mr
=
create
(
:merge_request
,
source_project:
project1
)
mr
=
create
(
:merge_request
,
source_project:
project1
)
mr
.
metrics
.
update!
(
merged_at:
1
.
hour
.
from_now
)
mr
.
metrics
.
update!
(
merged_at:
1
.
hour
.
from_now
)
...
...
ee/spec/lib/gitlab/analytics/cycle_analytics/request_params_spec.rb
View file @
8f6bcd01
...
@@ -42,7 +42,7 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::RequestParams do
...
@@ -42,7 +42,7 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::RequestParams do
end
end
it
'is valid'
do
it
'is valid'
do
Timecop
.
travel
'2019-03-01'
do
travel_to
'2019-03-01'
do
expect
(
subject
).
to
be_valid
expect
(
subject
).
to
be_valid
end
end
end
end
...
...
ee/spec/lib/gitlab/geo/event_gap_tracking_spec.rb
View file @
8f6bcd01
...
@@ -19,12 +19,12 @@ RSpec.describe Gitlab::Geo::EventGapTracking, :clean_gitlab_redis_cache do
...
@@ -19,12 +19,12 @@ RSpec.describe Gitlab::Geo::EventGapTracking, :clean_gitlab_redis_cache do
end
end
it
'returns the lowest gap id'
do
it
'returns the lowest gap id'
do
Timecop
.
travel
(
50
.
minutes
.
ago
)
do
travel_to
(
50
.
minutes
.
ago
)
do
gap_tracking
.
previous_id
=
18
gap_tracking
.
previous_id
=
18
gap_tracking
.
send
(
:track_gaps
,
20
)
gap_tracking
.
send
(
:track_gaps
,
20
)
end
end
Timecop
.
travel
(
40
.
minutes
.
ago
)
do
travel_to
(
40
.
minutes
.
ago
)
do
gap_tracking
.
previous_id
=
12
gap_tracking
.
previous_id
=
12
gap_tracking
.
send
(
:track_gaps
,
14
)
gap_tracking
.
send
(
:track_gaps
,
14
)
end
end
...
@@ -116,7 +116,7 @@ RSpec.describe Gitlab::Geo::EventGapTracking, :clean_gitlab_redis_cache do
...
@@ -116,7 +116,7 @@ RSpec.describe Gitlab::Geo::EventGapTracking, :clean_gitlab_redis_cache do
yielded
<<
event_log
yielded
<<
event_log
end
end
Timecop
.
travel
(
13
.
minutes
.
ago
)
do
travel_to
(
13
.
minutes
.
ago
)
do
gap_tracking
.
check!
(
event_id_with_gap
)
gap_tracking
.
check!
(
event_id_with_gap
)
end
end
create
(
:geo_event_log
,
:updated_event
,
id:
gap_id
)
create
(
:geo_event_log
,
:updated_event
,
id:
gap_id
)
...
@@ -125,7 +125,7 @@ RSpec.describe Gitlab::Geo::EventGapTracking, :clean_gitlab_redis_cache do
...
@@ -125,7 +125,7 @@ RSpec.describe Gitlab::Geo::EventGapTracking, :clean_gitlab_redis_cache do
expect
{
gap_tracking
.
fill_gaps
(
&
blk
)
}.
to
change
{
yielded
.
count
}.
by
(
1
)
expect
{
gap_tracking
.
fill_gaps
(
&
blk
)
}.
to
change
{
yielded
.
count
}.
by
(
1
)
end
.
count
end
.
count
Timecop
.
travel
(
12
.
minutes
.
ago
)
do
travel_to
(
12
.
minutes
.
ago
)
do
gap_tracking
.
check!
(
event_id_with_gap
+
3
)
gap_tracking
.
check!
(
event_id_with_gap
+
3
)
end
end
create
(
:geo_event_log
,
:updated_event
,
id:
event_id_with_gap
+
1
)
create
(
:geo_event_log
,
:updated_event
,
id:
event_id_with_gap
+
1
)
...
...
ee/spec/lib/gitlab/geo/jwt_request_decoder_spec.rb
View file @
8f6bcd01
...
@@ -45,7 +45,7 @@ RSpec.describe Gitlab::Geo::JwtRequestDecoder do
...
@@ -45,7 +45,7 @@ RSpec.describe Gitlab::Geo::JwtRequestDecoder do
it
'successfully decodes when clocks are off by IAT leeway'
do
it
'successfully decodes when clocks are off by IAT leeway'
do
subject
subject
Timecop
.
travel
(
30
.
seconds
.
ago
)
{
expect
(
subject
.
decode
).
to
eq
(
data
)
}
travel_to
(
30
.
seconds
.
ago
)
{
expect
(
subject
.
decode
).
to
eq
(
data
)
}
end
end
it
'raises InvalidSignatureTimeError after expiring'
do
it
'raises InvalidSignatureTimeError after expiring'
do
...
@@ -57,7 +57,7 @@ RSpec.describe Gitlab::Geo::JwtRequestDecoder do
...
@@ -57,7 +57,7 @@ RSpec.describe Gitlab::Geo::JwtRequestDecoder do
it
'raises InvalidSignatureTimeError to decode when clocks are not in sync'
do
it
'raises InvalidSignatureTimeError to decode when clocks are not in sync'
do
subject
subject
Timecop
.
travel
(
2
.
minutes
.
ago
)
{
expect
{
subject
.
decode
}.
to
raise_error
(
Gitlab
::
Geo
::
InvalidSignatureTimeError
)
}
travel_to
(
2
.
minutes
.
ago
)
{
expect
{
subject
.
decode
}.
to
raise_error
(
Gitlab
::
Geo
::
InvalidSignatureTimeError
)
}
end
end
it
'raises invalid decryption key error'
do
it
'raises invalid decryption key error'
do
...
...
ee/spec/models/ee/namespace/root_storage_size_spec.rb
View file @
8f6bcd01
...
@@ -152,7 +152,7 @@ RSpec.describe EE::Namespace::RootStorageSize do
...
@@ -152,7 +152,7 @@ RSpec.describe EE::Namespace::RootStorageSize do
subject
{
model
.
enforce_limit?
}
subject
{
model
.
enforce_limit?
}
around
do
|
example
|
around
do
|
example
|
Timecop
.
travel
(
current_date
)
{
example
.
run
}
travel_to
(
current_date
)
{
example
.
run
}
end
end
context
'when current date is before enforcement date'
do
context
'when current date is before enforcement date'
do
...
...
ee/spec/models/gitlab/seat_link_data_spec.rb
View file @
8f6bcd01
...
@@ -35,7 +35,7 @@ RSpec.describe Gitlab::SeatLinkData do
...
@@ -35,7 +35,7 @@ RSpec.describe Gitlab::SeatLinkData do
end
end
around
do
|
example
|
around
do
|
example
|
Timecop
.
travel
(
utc_time
)
{
example
.
run
}
travel_to
(
utc_time
)
{
example
.
run
}
end
end
context
'when passing no params'
do
context
'when passing no params'
do
...
...
ee/spec/requests/rack_attack_spec.rb
View file @
8f6bcd01
...
@@ -55,7 +55,7 @@ RSpec.describe 'Rack Attack EE throttles' do
...
@@ -55,7 +55,7 @@ RSpec.describe 'Rack Attack EE throttles' do
expect_rejection
{
post
(
path
,
**
post_args
)
}
expect_rejection
{
post
(
path
,
**
post_args
)
}
Timecop
.
travel
(
period
.
from_now
)
do
travel_to
(
period
.
from_now
)
do
requests_per_period
.
times
do
requests_per_period
.
times
do
post
(
path
,
**
post_args
)
post
(
path
,
**
post_args
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
...
...
ee/spec/support/shared_examples/controllers/analytics/cycle_analytics/shared_stage_shared_examples.rb
View file @
8f6bcd01
...
@@ -323,7 +323,7 @@ RSpec.shared_examples 'cycle analytics data endpoint examples' do
...
@@ -323,7 +323,7 @@ RSpec.shared_examples 'cycle analytics data endpoint examples' do
end
end
it
'succeeds'
do
it
'succeeds'
do
Timecop
.
travel
'2019-04-01'
do
travel_to
'2019-04-01'
do
subject
subject
expect
(
response
).
to
be_successful
expect
(
response
).
to
be_successful
...
...
ee/spec/workers/sync_seat_link_worker_spec.rb
View file @
8f6bcd01
...
@@ -22,7 +22,7 @@ RSpec.describe SyncSeatLinkWorker, type: :worker do
...
@@ -22,7 +22,7 @@ RSpec.describe SyncSeatLinkWorker, type: :worker do
end
end
it
'executes the SyncSeatLinkRequestWorker with expected params'
do
it
'executes the SyncSeatLinkRequestWorker with expected params'
do
Timecop
.
travel
(
utc_time
)
do
travel_to
(
utc_time
)
do
subject
.
perform
subject
.
perform
expect
(
SyncSeatLinkRequestWorker
).
to
have_received
(
:perform_async
)
expect
(
SyncSeatLinkRequestWorker
).
to
have_received
(
:perform_async
)
...
@@ -41,7 +41,7 @@ RSpec.describe SyncSeatLinkWorker, type: :worker do
...
@@ -41,7 +41,7 @@ RSpec.describe SyncSeatLinkWorker, type: :worker do
end
end
it
'executes the SyncSeatLinkRequestWorker with expected params'
do
it
'executes the SyncSeatLinkRequestWorker with expected params'
do
Timecop
.
travel
(
utc_time
)
do
travel_to
(
utc_time
)
do
expect
(
Date
.
current
.
to_s
).
to
eql
(
'2020-03-13'
)
expect
(
Date
.
current
.
to_s
).
to
eql
(
'2020-03-13'
)
subject
.
perform
subject
.
perform
...
@@ -62,7 +62,7 @@ RSpec.describe SyncSeatLinkWorker, type: :worker do
...
@@ -62,7 +62,7 @@ RSpec.describe SyncSeatLinkWorker, type: :worker do
end
end
it
'executes the SyncSeatLinkRequestWorker with expected params'
do
it
'executes the SyncSeatLinkRequestWorker with expected params'
do
Timecop
.
travel
(
utc_time
.
beginning_of_day
)
do
travel_to
(
utc_time
.
beginning_of_day
)
do
expect
(
Date
.
current
.
to_s
).
to
eql
(
'2020-03-11'
)
expect
(
Date
.
current
.
to_s
).
to
eql
(
'2020-03-11'
)
subject
.
perform
subject
.
perform
...
...
spec/features/admin/admin_mode/login_spec.rb
View file @
8f6bcd01
...
@@ -48,7 +48,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc
...
@@ -48,7 +48,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc
it
'allows login with valid code'
do
it
'allows login with valid code'
do
# Cannot reuse the TOTP
# Cannot reuse the TOTP
Timecop
.
travel
(
30
.
seconds
.
from_now
)
do
travel_to
(
30
.
seconds
.
from_now
)
do
enter_code
(
user
.
current_otp
)
enter_code
(
user
.
current_otp
)
expect
(
current_path
).
to
eq
admin_root_path
expect
(
current_path
).
to
eq
admin_root_path
...
@@ -58,7 +58,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc
...
@@ -58,7 +58,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc
it
'blocks login with invalid code'
do
it
'blocks login with invalid code'
do
# Cannot reuse the TOTP
# Cannot reuse the TOTP
Timecop
.
travel
(
30
.
seconds
.
from_now
)
do
travel_to
(
30
.
seconds
.
from_now
)
do
enter_code
(
'foo'
)
enter_code
(
'foo'
)
expect
(
page
).
to
have_content
(
'Invalid two-factor code'
)
expect
(
page
).
to
have_content
(
'Invalid two-factor code'
)
...
@@ -67,7 +67,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc
...
@@ -67,7 +67,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc
it
'allows login with invalid code, then valid code'
do
it
'allows login with invalid code, then valid code'
do
# Cannot reuse the TOTP
# Cannot reuse the TOTP
Timecop
.
travel
(
30
.
seconds
.
from_now
)
do
travel_to
(
30
.
seconds
.
from_now
)
do
enter_code
(
'foo'
)
enter_code
(
'foo'
)
expect
(
page
).
to
have_content
(
'Invalid two-factor code'
)
expect
(
page
).
to
have_content
(
'Invalid two-factor code'
)
...
@@ -163,7 +163,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc
...
@@ -163,7 +163,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc
expect
(
page
).
to
have_content
(
'Two-Factor Authentication'
)
expect
(
page
).
to
have_content
(
'Two-Factor Authentication'
)
# Cannot reuse the TOTP
# Cannot reuse the TOTP
Timecop
.
travel
(
30
.
seconds
.
from_now
)
do
travel_to
(
30
.
seconds
.
from_now
)
do
enter_code
(
user
.
current_otp
)
enter_code
(
user
.
current_otp
)
expect
(
current_path
).
to
eq
admin_root_path
expect
(
current_path
).
to
eq
admin_root_path
...
@@ -215,7 +215,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc
...
@@ -215,7 +215,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc
expect
(
page
).
to
have_content
(
'Two-Factor Authentication'
)
expect
(
page
).
to
have_content
(
'Two-Factor Authentication'
)
# Cannot reuse the TOTP
# Cannot reuse the TOTP
Timecop
.
travel
(
30
.
seconds
.
from_now
)
do
travel_to
(
30
.
seconds
.
from_now
)
do
enter_code
(
user
.
current_otp
)
enter_code
(
user
.
current_otp
)
expect
(
current_path
).
to
eq
admin_root_path
expect
(
current_path
).
to
eq
admin_root_path
...
...
spec/features/dashboard/issuables_counter_spec.rb
View file @
8f6bcd01
...
@@ -23,7 +23,7 @@ RSpec.describe 'Navigation bar counter', :use_clean_rails_memory_store_caching d
...
@@ -23,7 +23,7 @@ RSpec.describe 'Navigation bar counter', :use_clean_rails_memory_store_caching d
user
.
invalidate_cache_counts
user
.
invalidate_cache_counts
Timecop
.
travel
(
3
.
minutes
.
from_now
)
do
travel_to
(
3
.
minutes
.
from_now
)
do
visit
issues_path
visit
issues_path
expect_counters
(
'issues'
,
'0'
)
expect_counters
(
'issues'
,
'0'
)
...
@@ -39,7 +39,7 @@ RSpec.describe 'Navigation bar counter', :use_clean_rails_memory_store_caching d
...
@@ -39,7 +39,7 @@ RSpec.describe 'Navigation bar counter', :use_clean_rails_memory_store_caching d
user
.
invalidate_cache_counts
user
.
invalidate_cache_counts
Timecop
.
travel
(
3
.
minutes
.
from_now
)
do
travel_to
(
3
.
minutes
.
from_now
)
do
visit
merge_requests_path
visit
merge_requests_path
expect_counters
(
'merge_requests'
,
'0'
)
expect_counters
(
'merge_requests'
,
'0'
)
...
...
spec/lib/forever_spec.rb
View file @
8f6bcd01
...
@@ -7,7 +7,7 @@ RSpec.describe Forever do
...
@@ -7,7 +7,7 @@ RSpec.describe Forever do
subject
{
described_class
.
date
}
subject
{
described_class
.
date
}
it
'returns Postgresql future date'
do
it
'returns Postgresql future date'
do
Timecop
.
travel
(
Date
.
new
(
2999
,
12
,
31
))
do
travel_to
(
Date
.
new
(
2999
,
12
,
31
))
do
is_expected
.
to
be
>
Date
.
today
is_expected
.
to
be
>
Date
.
today
end
end
end
end
...
...
spec/lib/gitlab/auth/unique_ips_limiter_spec.rb
View file @
8f6bcd01
...
@@ -26,7 +26,7 @@ RSpec.describe Gitlab::Auth::UniqueIpsLimiter, :clean_gitlab_redis_shared_state
...
@@ -26,7 +26,7 @@ RSpec.describe Gitlab::Auth::UniqueIpsLimiter, :clean_gitlab_redis_shared_state
expect
(
described_class
.
update_and_return_ips_count
(
user
.
id
,
'ip2'
)).
to
eq
(
1
)
expect
(
described_class
.
update_and_return_ips_count
(
user
.
id
,
'ip2'
)).
to
eq
(
1
)
expect
(
described_class
.
update_and_return_ips_count
(
user
.
id
,
'ip3'
)).
to
eq
(
2
)
expect
(
described_class
.
update_and_return_ips_count
(
user
.
id
,
'ip3'
)).
to
eq
(
2
)
Timecop
.
travel
(
Time
.
now
.
utc
+
described_class
.
config
.
unique_ips_limit_time_window
)
do
travel_to
(
Time
.
now
.
utc
+
described_class
.
config
.
unique_ips_limit_time_window
)
do
expect
(
described_class
.
update_and_return_ips_count
(
user
.
id
,
'ip4'
)).
to
eq
(
1
)
expect
(
described_class
.
update_and_return_ips_count
(
user
.
id
,
'ip4'
)).
to
eq
(
1
)
expect
(
described_class
.
update_and_return_ips_count
(
user
.
id
,
'ip5'
)).
to
eq
(
2
)
expect
(
described_class
.
update_and_return_ips_count
(
user
.
id
,
'ip5'
)).
to
eq
(
2
)
end
end
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
8f6bcd01
...
@@ -1035,7 +1035,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
...
@@ -1035,7 +1035,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
def
for_defined_days_back
(
days:
[
31
,
3
])
def
for_defined_days_back
(
days:
[
31
,
3
])
days
.
each
do
|
n
|
days
.
each
do
|
n
|
Timecop
.
travel
(
n
.
days
.
ago
)
do
travel_to
(
n
.
days
.
ago
)
do
yield
yield
end
end
end
end
...
...
spec/requests/api/ci/runner/jobs_put_spec.rb
View file @
8f6bcd01
...
@@ -241,7 +241,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
...
@@ -241,7 +241,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
end
end
def
update_job_after_time
(
update_interval
=
20
.
minutes
,
state
=
'running'
)
def
update_job_after_time
(
update_interval
=
20
.
minutes
,
state
=
'running'
)
Timecop
.
travel
(
job
.
updated_at
+
update_interval
)
do
travel_to
(
job
.
updated_at
+
update_interval
)
do
update_job
(
job
.
token
,
state:
state
)
update_job
(
job
.
token
,
state:
state
)
end
end
end
end
...
...
spec/requests/rack_attack_global_spec.rb
View file @
8f6bcd01
...
@@ -68,7 +68,7 @@ RSpec.describe 'Rack Attack global throttles' do
...
@@ -68,7 +68,7 @@ RSpec.describe 'Rack Attack global throttles' do
expect_rejection
{
get
url_that_does_not_require_authentication
}
expect_rejection
{
get
url_that_does_not_require_authentication
}
Timecop
.
travel
(
period
.
from_now
)
do
travel_to
(
period
.
from_now
)
do
requests_per_period
.
times
do
requests_per_period
.
times
do
get
url_that_does_not_require_authentication
get
url_that_does_not_require_authentication
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
...
...
spec/services/ci/pipeline_processing/shared_processing_service.rb
View file @
8f6bcd01
...
@@ -259,14 +259,14 @@ RSpec.shared_examples 'Pipeline Processing Service' do
...
@@ -259,14 +259,14 @@ RSpec.shared_examples 'Pipeline Processing Service' do
expect
(
builds_names_and_statuses
).
to
eq
({
'build'
:
'success'
,
'rollout10%'
:
'scheduled'
})
expect
(
builds_names_and_statuses
).
to
eq
({
'build'
:
'success'
,
'rollout10%'
:
'scheduled'
})
Timecop
.
travel
2
.
minutes
.
from_now
do
travel_to
2
.
minutes
.
from_now
do
enqueue_scheduled
(
'rollout10%'
)
enqueue_scheduled
(
'rollout10%'
)
end
end
succeed_pending
succeed_pending
expect
(
builds_names_and_statuses
).
to
eq
({
'build'
:
'success'
,
'rollout10%'
:
'success'
,
'rollout100%'
:
'scheduled'
})
expect
(
builds_names_and_statuses
).
to
eq
({
'build'
:
'success'
,
'rollout10%'
:
'success'
,
'rollout100%'
:
'scheduled'
})
Timecop
.
travel
2
.
minutes
.
from_now
do
travel_to
2
.
minutes
.
from_now
do
enqueue_scheduled
(
'rollout100%'
)
enqueue_scheduled
(
'rollout100%'
)
end
end
succeed_pending
succeed_pending
...
@@ -330,7 +330,7 @@ RSpec.shared_examples 'Pipeline Processing Service' do
...
@@ -330,7 +330,7 @@ RSpec.shared_examples 'Pipeline Processing Service' do
expect
(
builds_names_and_statuses
).
to
eq
({
'build'
:
'success'
,
'rollout10%'
:
'scheduled'
})
expect
(
builds_names_and_statuses
).
to
eq
({
'build'
:
'success'
,
'rollout10%'
:
'scheduled'
})
Timecop
.
travel
2
.
minutes
.
from_now
do
travel_to
2
.
minutes
.
from_now
do
enqueue_scheduled
(
'rollout10%'
)
enqueue_scheduled
(
'rollout10%'
)
end
end
fail_running_or_pending
fail_running_or_pending
...
@@ -398,7 +398,7 @@ RSpec.shared_examples 'Pipeline Processing Service' do
...
@@ -398,7 +398,7 @@ RSpec.shared_examples 'Pipeline Processing Service' do
expect
(
process_pipeline
).
to
be_truthy
expect
(
process_pipeline
).
to
be_truthy
expect
(
builds_names_and_statuses
).
to
eq
({
'delayed1'
:
'scheduled'
,
'delayed2'
:
'scheduled'
})
expect
(
builds_names_and_statuses
).
to
eq
({
'delayed1'
:
'scheduled'
,
'delayed2'
:
'scheduled'
})
Timecop
.
travel
2
.
minutes
.
from_now
do
travel_to
2
.
minutes
.
from_now
do
enqueue_scheduled
(
'delayed1'
)
enqueue_scheduled
(
'delayed1'
)
end
end
...
@@ -419,7 +419,7 @@ RSpec.shared_examples 'Pipeline Processing Service' do
...
@@ -419,7 +419,7 @@ RSpec.shared_examples 'Pipeline Processing Service' do
expect
(
process_pipeline
).
to
be_truthy
expect
(
process_pipeline
).
to
be_truthy
expect
(
builds_names_and_statuses
).
to
eq
({
'delayed'
:
'scheduled'
})
expect
(
builds_names_and_statuses
).
to
eq
({
'delayed'
:
'scheduled'
})
Timecop
.
travel
2
.
minutes
.
from_now
do
travel_to
2
.
minutes
.
from_now
do
enqueue_scheduled
(
'delayed'
)
enqueue_scheduled
(
'delayed'
)
end
end
fail_running_or_pending
fail_running_or_pending
...
...
spec/services/deployments/update_environment_service_spec.rb
View file @
8f6bcd01
...
@@ -258,7 +258,7 @@ RSpec.describe Deployments::UpdateEnvironmentService do
...
@@ -258,7 +258,7 @@ RSpec.describe Deployments::UpdateEnvironmentService do
expect
(
merge_request
.
reload
.
metrics
.
first_deployed_to_production_at
).
to
be_like_time
(
deployment
.
finished_at
)
expect
(
merge_request
.
reload
.
metrics
.
first_deployed_to_production_at
).
to
be_like_time
(
deployment
.
finished_at
)
# Current deploy
# Current deploy
Timecop
.
travel
(
12
.
hours
.
from_now
)
do
travel_to
(
12
.
hours
.
from_now
)
do
service
.
execute
service
.
execute
expect
(
merge_request
.
reload
.
metrics
.
first_deployed_to_production_at
).
to
be_like_time
(
deployment
.
finished_at
)
expect
(
merge_request
.
reload
.
metrics
.
first_deployed_to_production_at
).
to
be_like_time
(
deployment
.
finished_at
)
...
...
spec/support/helpers/usage_data_helpers.rb
View file @
8f6bcd01
...
@@ -236,7 +236,7 @@ module UsageDataHelpers
...
@@ -236,7 +236,7 @@ module UsageDataHelpers
def
for_defined_days_back
(
days:
[
31
,
3
])
def
for_defined_days_back
(
days:
[
31
,
3
])
days
.
each
do
|
n
|
days
.
each
do
|
n
|
Timecop
.
travel
(
n
.
days
.
ago
)
do
travel_to
(
n
.
days
.
ago
)
do
yield
yield
end
end
end
end
...
...
spec/support/shared_examples/requests/rack_attack_shared_examples.rb
View file @
8f6bcd01
...
@@ -48,7 +48,7 @@ RSpec.shared_examples 'rate-limited token-authenticated requests' do
...
@@ -48,7 +48,7 @@ RSpec.shared_examples 'rate-limited token-authenticated requests' do
expect_rejection
{
make_request
(
request_args
)
}
expect_rejection
{
make_request
(
request_args
)
}
Timecop
.
travel
(
period
.
from_now
)
do
travel_to
(
period
.
from_now
)
do
requests_per_period
.
times
do
requests_per_period
.
times
do
make_request
(
request_args
)
make_request
(
request_args
)
expect
(
response
).
not_to
have_gitlab_http_status
(
:too_many_requests
)
expect
(
response
).
not_to
have_gitlab_http_status
(
:too_many_requests
)
...
@@ -175,7 +175,7 @@ RSpec.shared_examples 'rate-limited web authenticated requests' do
...
@@ -175,7 +175,7 @@ RSpec.shared_examples 'rate-limited web authenticated requests' do
expect_rejection
{
request_authenticated_web_url
}
expect_rejection
{
request_authenticated_web_url
}
Timecop
.
travel
(
period
.
from_now
)
do
travel_to
(
period
.
from_now
)
do
requests_per_period
.
times
do
requests_per_period
.
times
do
request_authenticated_web_url
request_authenticated_web_url
expect
(
response
).
not_to
have_gitlab_http_status
(
:too_many_requests
)
expect
(
response
).
not_to
have_gitlab_http_status
(
:too_many_requests
)
...
...
spec/support/shared_examples/services/boards/issues_move_service_shared_examples.rb
View file @
8f6bcd01
...
@@ -131,7 +131,7 @@ RSpec.shared_examples 'issues move service' do |group|
...
@@ -131,7 +131,7 @@ RSpec.shared_examples 'issues move service' do |group|
updated_at1
=
issue1
.
updated_at
updated_at1
=
issue1
.
updated_at
updated_at2
=
issue2
.
updated_at
updated_at2
=
issue2
.
updated_at
Timecop
.
travel
(
1
.
minute
.
from_now
)
do
travel_to
(
1
.
minute
.
from_now
)
do
described_class
.
new
(
parent
,
user
,
params
).
execute
(
issue
)
described_class
.
new
(
parent
,
user
,
params
).
execute
(
issue
)
end
end
...
...
spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb
View file @
8f6bcd01
...
@@ -17,7 +17,7 @@ RSpec.describe Metrics::Dashboard::PruneOldAnnotationsWorker do
...
@@ -17,7 +17,7 @@ RSpec.describe Metrics::Dashboard::PruneOldAnnotationsWorker do
# is idempotent in the scope of 24h
# is idempotent in the scope of 24h
expect
{
described_class
.
new
.
perform
}.
not_to
change
{
Metrics
::
Dashboard
::
Annotation
.
all
.
to_a
}
expect
{
described_class
.
new
.
perform
}.
not_to
change
{
Metrics
::
Dashboard
::
Annotation
.
all
.
to_a
}
Timecop
.
travel
(
24
.
hours
.
from_now
)
do
travel_to
(
24
.
hours
.
from_now
)
do
described_class
.
new
.
perform
described_class
.
new
.
perform
expect
(
Metrics
::
Dashboard
::
Annotation
.
all
).
to
match_array
([
one_day_old_annotation
])
expect
(
Metrics
::
Dashboard
::
Annotation
.
all
).
to
match_array
([
one_day_old_annotation
])
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