Commit 32e086bf authored by Alishan Ladhani's avatar Alishan Ladhani

Remove some usages of Timecop.freeze

To comply with RSpec/TimecopFreeze cop
parent c0c3f829
...@@ -695,14 +695,10 @@ RSpec/TimecopFreeze: ...@@ -695,14 +695,10 @@ RSpec/TimecopFreeze:
- 'ee/spec/services/vulnerability_exports/export_service_spec.rb' - 'ee/spec/services/vulnerability_exports/export_service_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'
- 'qa/spec/support/repeater_spec.rb' - 'qa/spec/support/repeater_spec.rb'
- 'spec/features/profiles/active_sessions_spec.rb'
- 'spec/features/projects/environments/environment_metrics_spec.rb'
- 'spec/features/users/active_sessions_spec.rb' - 'spec/features/users/active_sessions_spec.rb'
- 'spec/lib/atlassian/jira_connect/client_spec.rb'
- 'spec/lib/gitlab/analytics/cycle_analytics/base_query_builder_spec.rb' - 'spec/lib/gitlab/analytics/cycle_analytics/base_query_builder_spec.rb'
- 'spec/lib/gitlab/analytics/cycle_analytics/median_spec.rb' - 'spec/lib/gitlab/analytics/cycle_analytics/median_spec.rb'
- 'spec/lib/gitlab/analytics/cycle_analytics/records_fetcher_spec.rb' - 'spec/lib/gitlab/analytics/cycle_analytics/records_fetcher_spec.rb'
- 'spec/lib/gitlab/anonymous_session_spec.rb'
- 'spec/lib/gitlab/auth/unique_ips_limiter_spec.rb' - 'spec/lib/gitlab/auth/unique_ips_limiter_spec.rb'
- 'spec/lib/gitlab/checks/timed_logger_spec.rb' - 'spec/lib/gitlab/checks/timed_logger_spec.rb'
- 'spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb' - 'spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb'
...@@ -715,10 +711,6 @@ RSpec/TimecopFreeze: ...@@ -715,10 +711,6 @@ RSpec/TimecopFreeze:
- 'spec/lib/rspec_flaky/flaky_example_spec.rb' - 'spec/lib/rspec_flaky/flaky_example_spec.rb'
- 'spec/lib/rspec_flaky/listener_spec.rb' - 'spec/lib/rspec_flaky/listener_spec.rb'
- 'spec/models/active_session_spec.rb' - 'spec/models/active_session_spec.rb'
- 'spec/models/container_repository_spec.rb'
- 'spec/models/pages/lookup_path_spec.rb'
- 'spec/models/project_feature_usage_spec.rb'
- 'spec/requests/api/v3/github_spec.rb'
- 'spec/serializers/entity_date_helper_spec.rb' - 'spec/serializers/entity_date_helper_spec.rb'
- 'spec/support/cycle_analytics_helpers/test_generation.rb' - 'spec/support/cycle_analytics_helpers/test_generation.rb'
- 'spec/support/helpers/cycle_analytics_helpers.rb' - 'spec/support/helpers/cycle_analytics_helpers.rb'
......
...@@ -12,7 +12,7 @@ RSpec.describe 'Profile > Active Sessions', :clean_gitlab_redis_shared_state do ...@@ -12,7 +12,7 @@ RSpec.describe 'Profile > Active Sessions', :clean_gitlab_redis_shared_state do
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
it 'User sees their active sessions' do it 'User sees their active sessions' do
Timecop.freeze(Time.zone.parse('2018-03-12 09:06')) do travel_to(Time.zone.parse('2018-03-12 09:06')) do
Capybara::Session.new(:session1) Capybara::Session.new(:session1)
Capybara::Session.new(:session2) Capybara::Session.new(:session2)
Capybara::Session.new(:session3) Capybara::Session.new(:session3)
......
...@@ -22,7 +22,7 @@ RSpec.describe 'Environment > Metrics' do ...@@ -22,7 +22,7 @@ RSpec.describe 'Environment > Metrics' do
end end
around do |example| around do |example|
Timecop.freeze(current_time) { example.run } travel_to(current_time) { example.run }
end end
shared_examples 'has environment selector' do shared_examples 'has environment selector' do
......
...@@ -8,7 +8,7 @@ RSpec.describe Atlassian::JiraConnect::Client do ...@@ -8,7 +8,7 @@ RSpec.describe Atlassian::JiraConnect::Client do
subject { described_class.new('https://gitlab-test.atlassian.net', 'sample_secret') } subject { described_class.new('https://gitlab-test.atlassian.net', 'sample_secret') }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
describe '.generate_update_sequence_id' do describe '.generate_update_sequence_id' do
......
...@@ -22,7 +22,7 @@ RSpec.describe Gitlab::AnonymousSession, :clean_gitlab_redis_shared_state do ...@@ -22,7 +22,7 @@ RSpec.describe Gitlab::AnonymousSession, :clean_gitlab_redis_shared_state do
end end
it 'adds expiration time to key' do it 'adds expiration time to key' do
Timecop.freeze do freeze_time do
subject.count_session_ip subject.count_session_ip
Gitlab::Redis::SharedState.with do |redis| Gitlab::Redis::SharedState.with do |redis|
......
...@@ -188,7 +188,7 @@ RSpec.describe ContainerRepository do ...@@ -188,7 +188,7 @@ RSpec.describe ContainerRepository do
subject { repository.start_expiration_policy! } subject { repository.start_expiration_policy! }
it 'sets the expiration policy started at to now' do it 'sets the expiration policy started at to now' do
Timecop.freeze do freeze_time do
expect { subject } expect { subject }
.to change { repository.expiration_policy_started_at }.from(nil).to(Time.zone.now) .to change { repository.expiration_policy_started_at }.from(nil).to(Time.zone.now)
end end
......
...@@ -65,7 +65,7 @@ RSpec.describe Pages::LookupPath do ...@@ -65,7 +65,7 @@ RSpec.describe Pages::LookupPath do
end end
it 'uses deployment from object storage' do it 'uses deployment from object storage' do
Timecop.freeze do freeze_time do
expect(source).to( expect(source).to(
eq({ eq({
type: 'zip', type: 'zip',
...@@ -85,7 +85,7 @@ RSpec.describe Pages::LookupPath do ...@@ -85,7 +85,7 @@ RSpec.describe Pages::LookupPath do
end end
it 'uses file protocol' do it 'uses file protocol' do
Timecop.freeze do freeze_time do
expect(source).to( expect(source).to(
eq({ eq({
type: 'zip', type: 'zip',
......
...@@ -25,7 +25,7 @@ RSpec.describe ProjectFeatureUsage, type: :model do ...@@ -25,7 +25,7 @@ RSpec.describe ProjectFeatureUsage, type: :model do
subject { project.feature_usage } subject { project.feature_usage }
it 'logs Jira DVCS Cloud last sync' do it 'logs Jira DVCS Cloud last sync' do
Timecop.freeze do freeze_time do
subject.log_jira_dvcs_integration_usage subject.log_jira_dvcs_integration_usage
expect(subject.jira_dvcs_server_last_sync_at).to be_nil expect(subject.jira_dvcs_server_last_sync_at).to be_nil
...@@ -34,7 +34,7 @@ RSpec.describe ProjectFeatureUsage, type: :model do ...@@ -34,7 +34,7 @@ RSpec.describe ProjectFeatureUsage, type: :model do
end end
it 'logs Jira DVCS Server last sync' do it 'logs Jira DVCS Server last sync' do
Timecop.freeze do freeze_time do
subject.log_jira_dvcs_integration_usage(cloud: false) subject.log_jira_dvcs_integration_usage(cloud: false)
expect(subject.jira_dvcs_server_last_sync_at).to be_like_time(Time.current) expect(subject.jira_dvcs_server_last_sync_at).to be_like_time(Time.current)
......
...@@ -383,7 +383,7 @@ RSpec.describe API::V3::Github do ...@@ -383,7 +383,7 @@ RSpec.describe API::V3::Github do
it 'counts Jira Cloud integration as enabled' do it 'counts Jira Cloud integration as enabled' do
user_agent = 'Jira DVCS Connector Vertigo/4.42.0' user_agent = 'Jira DVCS Connector Vertigo/4.42.0'
Timecop.freeze do freeze_time do
jira_get v3_api("/repos/#{project.namespace.path}/#{project.path}/branches", user), user_agent jira_get v3_api("/repos/#{project.namespace.path}/#{project.path}/branches", user), user_agent
expect(project.reload.jira_dvcs_cloud_last_sync_at).to be_like_time(Time.now) expect(project.reload.jira_dvcs_cloud_last_sync_at).to be_like_time(Time.now)
...@@ -393,7 +393,7 @@ RSpec.describe API::V3::Github do ...@@ -393,7 +393,7 @@ RSpec.describe API::V3::Github do
it 'counts Jira Server integration as enabled' do it 'counts Jira Server integration as enabled' do
user_agent = 'Jira DVCS Connector/3.2.4' user_agent = 'Jira DVCS Connector/3.2.4'
Timecop.freeze do freeze_time do
jira_get v3_api("/repos/#{project.namespace.path}/#{project.path}/branches", user), user_agent jira_get v3_api("/repos/#{project.namespace.path}/#{project.path}/branches", user), user_agent
expect(project.reload.jira_dvcs_server_last_sync_at).to be_like_time(Time.now) expect(project.reload.jira_dvcs_server_last_sync_at).to be_like_time(Time.now)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment