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

63 lines
1.7 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'
2021-09-04 01:27:46 +05:30
RSpec.describe Gitlab::Checks::SingleChangeAccess do
2020-10-24 23:57:45 +05:30
describe '#validate!' 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
2020-10-24 23:57:45 +05:30
expect { subject.validate! }.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
2020-10-24 23:57:45 +05:30
subject.validate!
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
2020-10-24 23:57:45 +05:30
subject.validate!
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
2020-10-24 23:57:45 +05:30
subject.validate!
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 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
2020-10-24 23:57:45 +05:30
subject.validate!
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
2020-10-24 23:57:45 +05:30
expect { access.validate! }.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