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
|
2018-12-23 12:14:25 +05:30
|
|
|
include_context 'change access checks context'
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-23 12:14:25 +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
|
|
|
|
|
2018-12-23 12:14:25 +05:30
|
|
|
it 'calls pushes checks' do
|
|
|
|
expect_any_instance_of(Gitlab::Checks::PushCheck).to receive(:validate!)
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2018-12-23 12:14:25 +05:30
|
|
|
subject.exec
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
|
|
|
|
2018-12-23 12:14:25 +05:30
|
|
|
it 'calls branches checks' do
|
|
|
|
expect_any_instance_of(Gitlab::Checks::BranchCheck).to receive(:validate!)
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2018-12-23 12:14:25 +05:30
|
|
|
subject.exec
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
|
2018-12-23 12:14:25 +05:30
|
|
|
it 'calls tags checks' do
|
|
|
|
expect_any_instance_of(Gitlab::Checks::TagCheck).to receive(:validate!)
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2018-12-23 12:14:25 +05:30
|
|
|
subject.exec
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-23 12:14:25 +05:30
|
|
|
it 'calls lfs checks' do
|
|
|
|
expect_any_instance_of(Gitlab::Checks::LfsCheck).to receive(:validate!)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-23 12:14:25 +05:30
|
|
|
subject.exec
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2018-12-23 12:14:25 +05:30
|
|
|
it 'calls diff checks' do
|
|
|
|
expect_any_instance_of(Gitlab::Checks::DiffCheck).to receive(:validate!)
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-12-23 12:14:25 +05:30
|
|
|
subject.exec
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-12-23 12:14:25 +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)
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-12-23 12:14:25 +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
|