Commit e937e539 authored by Rémy Coutable's avatar Rémy Coutable

[EE] Enable Timecop safe mode

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 8616c079
......@@ -15,11 +15,13 @@ describe 'Issue Boards', js: true do
let!(:list) { create(:list, board: board, label: development, position: 0) }
let(:card) { find('.board:nth-child(2)').first('.card') }
around do |example|
Timecop.freeze { example.run }
end
before do
Timecop.freeze
stub_licensed_features(multiple_issue_assignees: false)
project.team << [user, :master]
project.add_master(user)
sign_in(user)
......@@ -27,10 +29,6 @@ describe 'Issue Boards', js: true do
wait_for_requests
end
after do
Timecop.return
end
it 'shows sidebar when clicking issue' do
click_card(card)
......
......@@ -5,14 +5,12 @@ feature 'Group milestones', :js do
let!(:project) { create(:project_empty_repo, group: group) }
let(:user) { create(:group_member, :master, user: create(:user), group: group ).user }
before do
Timecop.freeze
sign_in(user)
around do |example|
Timecop.freeze { example.run }
end
after do
Timecop.return
before do
sign_in(user)
end
context 'create a milestone' do
......
......@@ -175,11 +175,7 @@ describe Gitlab::Git::Storage::CircuitBreaker, clean_gitlab_redis_shared_state:
describe '#track_storage_inaccessible' do
around do |example|
Timecop.freeze
example.run
Timecop.return
Timecop.freeze { example.run }
end
it 'records the failure time in redis' do
......
......@@ -4,10 +4,6 @@ describe Gitlab::Metrics::RequestsRackMiddleware do
let(:app) { double('app') }
subject { described_class.new(app) }
around do |example|
Timecop.freeze { example.run }
end
describe '#call' do
let(:status) { 100 }
let(:env) { { 'REQUEST_METHOD' => 'GET' } }
......@@ -28,16 +24,14 @@ describe Gitlab::Metrics::RequestsRackMiddleware do
subject.call(env)
end
it 'measures execution time' do
execution_time = 10
allow(app).to receive(:call) do |*args|
Timecop.freeze(execution_time.seconds)
[200, nil, nil]
end
RSpec::Matchers.define :a_positive_execution_time do
match { |actual| actual > 0 }
end
expect(described_class).to receive_message_chain(:http_request_duration_seconds, :observe).with({ status: 200, method: 'get' }, execution_time)
it 'measures execution time' do
expect(described_class).to receive_message_chain(:http_request_duration_seconds, :observe).with({ status: 200, method: 'get' }, a_positive_execution_time)
subject.call(env)
Timecop.scale(3600) { subject.call(env) }
end
end
......
......@@ -57,18 +57,14 @@ describe Issue do
end
describe '#closed_at' do
after do
Timecop.return
end
let!(:now) { Timecop.freeze(Time.now) }
it 'sets closed_at to Time.now when issue is closed' do
issue = create(:issue, state: 'opened')
expect(issue.closed_at).to be_nil
issue.close
expect(issue.closed_at).to eq(now)
expect(issue.closed_at).to be_present
end
end
......
......@@ -229,13 +229,12 @@ describe API::Internal do
describe "POST /internal/allowed", :clean_gitlab_redis_shared_state do
context "access granted" do
before do
project.team << [user, :developer]
Timecop.freeze
around do |example|
Timecop.freeze { example.run }
end
after do
Timecop.return
before do
project.team << [user, :developer]
end
context 'with env passed as a JSON' do
......
......@@ -13,12 +13,8 @@ describe AnalyticsBuildEntity do
subject { entity.as_json }
before do
Timecop.freeze
end
after do
Timecop.return
around do |example|
Timecop.freeze { example.run }
end
it 'contains the URL' do
......
......@@ -83,6 +83,7 @@ RSpec.configure do |config|
end
config.before(:suite) do
Timecop.safe_mode = true
TestEnv.init
end
......
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