summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/checks/changes_access_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/checks/changes_access_spec.rb')
-rw-r--r--spec/lib/gitlab/checks/changes_access_spec.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/lib/gitlab/checks/changes_access_spec.rb b/spec/lib/gitlab/checks/changes_access_spec.rb
new file mode 100644
index 00000000000..a46732f8255
--- /dev/null
+++ b/spec/lib/gitlab/checks/changes_access_spec.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::Checks::ChangesAccess do
+ describe '#validate!' do
+ include_context 'changes access checks context'
+
+ before do
+ allow(project).to receive(:lfs_enabled?).and_return(true)
+ end
+
+ subject { changes_access }
+
+ context 'without failed checks' do
+ it "doesn't raise an error" do
+ expect { subject.validate! }.not_to raise_error
+ end
+
+ it 'calls lfs checks' do
+ expect_next_instance_of(Gitlab::Checks::LfsCheck) do |instance|
+ expect(instance).to receive(:validate!)
+ end
+
+ subject.validate!
+ end
+ end
+
+ 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)
+
+ expect { access.validate! }.to raise_error(Gitlab::Checks::TimedLogger::TimeoutError)
+ end
+ end
+ end
+end