Commit a785cfa8 authored by Etienne Baqué's avatar Etienne Baqué

Updated condition to raise DiskAccessDenied

Updated pages_path in Project class as well.
Updated tests accordingly.
parent d485ff60
......@@ -6,9 +6,7 @@ module Gitlab
DiskAccessDenied = Class.new(StandardError)
def path
if ::Gitlab::Runtime.web_server? && !::Gitlab::Runtime.test_suite?
raise DiskAccessDenied
end
::Gitlab::ErrorTracking.track_exception(DiskAccessDenied.new) if disk_access_denied?
super
end
......@@ -16,6 +14,14 @@ module Gitlab
def local_store
@local_store ||= ::Gitlab::Pages::Stores::LocalStore.new(super)
end
private
def disk_access_denied?
return true unless ::Settings.pages.local_store&.enabled
::Gitlab::Runtime.web_server? && !::Gitlab::Runtime.test_suite?
end
end
end
end
......@@ -16,8 +16,34 @@ RSpec.describe Gitlab::Pages::Settings do
allow(::Gitlab::Runtime).to receive(:web_server?).and_return(true)
end
it 'raises a DiskAccessDenied exception' do
expect { subject }.to raise_error(described_class::DiskAccessDenied)
it 'logs a DiskAccessDenied error' do
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
instance_of(described_class::DiskAccessDenied)
)
subject
end
end
context 'when local_store settings does not exist yet' do
before do
allow(Settings.pages).to receive(:local_store).and_return(nil)
end
it { is_expected.to eq('the path') }
end
context 'when local store exists but legacy storage is disabled' do
before do
allow(Settings.pages.local_store).to receive(:enabled).and_return(false)
end
it 'logs a DiskAccessDenied error' do
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
instance_of(described_class::DiskAccessDenied)
)
subject
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment