Commit 8b5352b5 authored by Peter Leitzen's avatar Peter Leitzen

Fetch storage client from status page settings

parent 9b28dc85
......@@ -41,6 +41,17 @@ class StatusPageSetting < ApplicationRecord
project&.beta_feature_available?(:status_page)
end
def storage_client
return unless enabled?
StatusPage::Storage::S3Client.new(
region: aws_region,
bucket_name: aws_s3_bucket_name,
access_key_id: aws_access_key,
secret_access_key: aws_secret_key
)
end
private
def check_secret_changes
......
......@@ -109,4 +109,27 @@ describe StatusPageSetting do
it { is_expected.to eq(false) }
end
end
describe '#storage_client' do
let(:status_page_setting) { build(:status_page_setting, :enabled) }
before do
allow(status_page_setting)
.to receive(:enabled?).and_return(status_page_setting_enabled)
end
subject { status_page_setting.storage_client }
context 'when status page settings is enabled' do
let(:status_page_setting_enabled) { true }
it { is_expected.to be_instance_of(StatusPage::Storage::S3Client) }
end
context 'when not enabled' do
let(:status_page_setting_enabled) { false }
it { is_expected.to be_nil }
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