debian-mirror-gitlab/spec/lib/gitlab/checks/change_access_spec.rb

71 lines
1.9 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2016-09-13 17:45:13 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe Gitlab::Checks::ChangeAccess do
2016-09-13 17:45:13 +05:30
describe '#exec' do
2019-02-15 15:39:39 +05:30
include_context 'change access checks context'
2017-08-17 22:00:37 +05:30
2019-02-15 15:39:39 +05:30
subject { change_access }
2016-09-13 17:45:13 +05:30
context 'without failed checks' do
2017-09-10 17:25:29 +05:30
it "doesn't raise an error" do
2018-03-17 18:26:18 +05:30
expect { subject.exec }.not_to raise_error
2016-09-13 17:45:13 +05:30
end
2019-02-15 15:39:39 +05:30
it 'calls pushes checks' do
2020-01-01 13:55:28 +05:30
expect_next_instance_of(Gitlab::Checks::PushCheck) do |instance|
expect(instance).to receive(:validate!)
end
2018-12-13 13:39:08 +05:30
2019-02-15 15:39:39 +05:30
subject.exec
2018-12-13 13:39:08 +05:30
end
2019-02-15 15:39:39 +05:30
it 'calls branches checks' do
2020-01-01 13:55:28 +05:30
expect_next_instance_of(Gitlab::Checks::BranchCheck) do |instance|
expect(instance).to receive(:validate!)
end
2016-09-13 17:45:13 +05:30
2019-02-15 15:39:39 +05:30
subject.exec
2016-09-13 17:45:13 +05:30
end
2019-02-15 15:39:39 +05:30
it 'calls tags checks' do
2020-01-01 13:55:28 +05:30
expect_next_instance_of(Gitlab::Checks::TagCheck) do |instance|
expect(instance).to receive(:validate!)
end
2016-09-13 17:45:13 +05:30
2019-02-15 15:39:39 +05:30
subject.exec
2016-09-13 17:45:13 +05:30
end
2017-08-17 22:00:37 +05:30
2019-02-15 15:39:39 +05:30
it 'calls lfs checks' do
2020-01-01 13:55:28 +05:30
expect_next_instance_of(Gitlab::Checks::LfsCheck) do |instance|
expect(instance).to receive(:validate!)
end
2017-08-17 22:00:37 +05:30
2019-02-15 15:39:39 +05:30
subject.exec
2017-08-17 22:00:37 +05:30
end
2016-09-13 17:45:13 +05:30
2019-02-15 15:39:39 +05:30
it 'calls diff checks' do
2020-01-01 13:55:28 +05:30
expect_next_instance_of(Gitlab::Checks::DiffCheck) do |instance|
expect(instance).to receive(:validate!)
end
2017-09-10 17:25:29 +05:30
2019-02-15 15:39:39 +05:30
subject.exec
2016-09-13 17:45:13 +05:30
end
end
2018-03-17 18:26:18 +05:30
2019-02-15 15:39:39 +05:30
context 'when time limit was reached' do
it 'raises a TimeoutError' do
logger = Gitlab::Checks::TimedLogger.new(start_time: timeout.ago, timeout: timeout)
access = described_class.new(changes,
project: project,
user_access: user_access,
protocol: protocol,
logger: logger)
2019-01-03 12:48:30 +05:30
2019-02-15 15:39:39 +05:30
expect { access.exec }.to raise_error(Gitlab::Checks::TimedLogger::TimeoutError)
2018-03-17 18:26:18 +05:30
end
end
2016-09-13 17:45:13 +05:30
end
end