Commit 90e14fc5 authored by Sean Arnold's avatar Sean Arnold

Add status page license and check

- Controller check
- Attribute in helper
- Specs to test
parent e952301e
......@@ -41,6 +41,10 @@ module EE
project.feature_available?(:tracing, current_user)
end
def has_status_page_licence?
project.feature_available?(:status_page, current_user)
end
def track_tracing_external_url
external_url_previous_change = project&.tracing_setting&.external_url_previous_change
return unless external_url_previous_change
......@@ -58,7 +62,9 @@ module EE
permitted_params[:tracing_setting_attributes] = [:external_url]
end
permitted_params.merge!(status_page_setting_params)
if has_status_page_licence?
permitted_params.merge!(status_page_setting_params)
end
permitted_params
end
......
......@@ -22,6 +22,7 @@ module OperationsHelper
def status_page_settings_data(status_page_setting)
{
'user-can-enable-status-page' => can?(current_user, :admin_operations, project).to_s,
'setting-enabled' => status_page_setting&.enabled?,
'setting-aws-access-key' => status_page_setting&.aws_access_key,
'setting-masked-aws-secret-key' => status_page_setting&.masked_aws_secret_key,
......
......@@ -117,6 +117,15 @@ describe Projects::Settings::OperationsController do
expect(project.tracing_setting).to be_nil
end
it 'does not create status_page_setting' do
update_project(
project,
status_page_params: attributes_for(:status_page_setting)
)
expect(project.status_page_setting).to be_nil
end
end
context 'format html' do
......@@ -158,7 +167,7 @@ describe Projects::Settings::OperationsController do
context 'with a license' do
before do
stub_licensed_features(tracing: true, incident_management: true)
stub_licensed_features(tracing: true, incident_management: true, status_page: true)
end
shared_examples 'user with write access' do |project_visibility|
......@@ -324,7 +333,7 @@ describe Projects::Settings::OperationsController do
context 'without a license' do
before do
stub_licensed_features(tracing: false, incident_management: false)
stub_licensed_features(tracing: false, incident_management: false, status_page: false)
end
it_behaves_like 'user without write access', :public, :maintainer
......
......@@ -6,12 +6,17 @@ describe OperationsHelper do
describe '#status_page_settings_data' do
subject { helper.status_page_settings_data(status_page_setting) }
before do
allow(helper).to receive(:can?) { true }
end
context 'setting does not exist' do
let(:status_page_setting) { nil }
it 'returns the correct values' do
expect(subject.keys)
.to contain_exactly(
'user-can-enable-status-page',
'setting-enabled',
'setting-aws-access-key',
'setting-masked-aws-secret-key',
......
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