2016-08-12 22:27:42 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 14:24:02 +00:00
|
|
|
describe Gitlab::Checks::ChangeAccess do
|
2016-08-12 22:27:42 +00:00
|
|
|
describe '#exec' do
|
2018-12-04 11:55:49 +00:00
|
|
|
include_context 'change access checks context'
|
2016-08-12 22:27:42 +00:00
|
|
|
|
2018-12-04 11:55:49 +00:00
|
|
|
subject { change_access }
|
2016-08-12 22:27:42 +00:00
|
|
|
|
|
|
|
context 'without failed checks' do
|
2017-05-19 19:58:45 +00:00
|
|
|
it "doesn't raise an error" do
|
2017-10-17 11:45:59 +00:00
|
|
|
expect { subject.exec }.not_to raise_error
|
2016-08-12 22:27:42 +00:00
|
|
|
end
|
|
|
|
|
2018-12-04 11:55:49 +00:00
|
|
|
it 'calls pushes checks' do
|
|
|
|
expect_any_instance_of(Gitlab::Checks::PushCheck).to receive(:validate!)
|
2018-10-22 14:49:20 +00:00
|
|
|
|
2018-12-04 11:55:49 +00:00
|
|
|
subject.exec
|
2018-10-22 14:49:20 +00:00
|
|
|
end
|
|
|
|
|
2018-12-04 11:55:49 +00:00
|
|
|
it 'calls branches checks' do
|
|
|
|
expect_any_instance_of(Gitlab::Checks::BranchCheck).to receive(:validate!)
|
2016-08-12 22:27:42 +00:00
|
|
|
|
2018-12-04 11:55:49 +00:00
|
|
|
subject.exec
|
2016-08-12 22:27:42 +00:00
|
|
|
end
|
|
|
|
|
2018-12-04 11:55:49 +00:00
|
|
|
it 'calls tags checks' do
|
|
|
|
expect_any_instance_of(Gitlab::Checks::TagCheck).to receive(:validate!)
|
2016-08-12 22:27:42 +00:00
|
|
|
|
2018-12-04 11:55:49 +00:00
|
|
|
subject.exec
|
2016-08-12 22:27:42 +00:00
|
|
|
end
|
2017-03-31 16:57:29 +00:00
|
|
|
|
2018-12-04 11:55:49 +00:00
|
|
|
it 'calls lfs checks' do
|
|
|
|
expect_any_instance_of(Gitlab::Checks::LfsCheck).to receive(:validate!)
|
2017-03-31 16:57:29 +00:00
|
|
|
|
2018-12-04 11:55:49 +00:00
|
|
|
subject.exec
|
2017-03-31 16:57:29 +00:00
|
|
|
end
|
2016-08-12 22:27:42 +00:00
|
|
|
|
2018-12-04 11:55:49 +00:00
|
|
|
it 'calls diff checks' do
|
|
|
|
expect_any_instance_of(Gitlab::Checks::DiffCheck).to receive(:validate!)
|
2016-08-12 22:27:42 +00:00
|
|
|
|
2018-12-04 11:55:49 +00:00
|
|
|
subject.exec
|
2016-08-12 22:27:42 +00:00
|
|
|
end
|
|
|
|
end
|
2017-08-25 01:30:12 +00:00
|
|
|
|
2018-12-04 11:55:49 +00:00
|
|
|
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-02-07 13:00:53 +00:00
|
|
|
|
2018-12-04 11:55:49 +00:00
|
|
|
expect { access.exec }.to raise_error(Gitlab::Checks::TimedLogger::TimeoutError)
|
2018-02-07 13:00:53 +00:00
|
|
|
end
|
|
|
|
end
|
2016-08-12 22:27:42 +00:00
|
|
|
end
|
|
|
|
end
|