Commit 3c6492ea authored by Vladimir Shushlin's avatar Vladimir Shushlin Committed by Robert Speicher

Remove feature_flag_audit feature flag

Remove feature flag and specs for it being turned off
parent 90b9f50a
......@@ -6,13 +6,7 @@ module FeatureFlags
protected
def audit_enabled?
Feature.enabled?(:feature_flag_audit, project, default_enabled: true)
end
def audit_event(feature_flag)
return unless audit_enabled?
message = audit_message(feature_flag)
return if message.blank?
......@@ -33,7 +27,7 @@ module FeatureFlags
end
def save_audit_event(audit_event)
return unless audit_event # feature_flag_audit is disabled or audit_message is blank
return unless audit_event
audit_event.security_event
end
......
......@@ -15,182 +15,120 @@ describe 'User creates feature flag', :js do
end
context 'when creates without changing scopes' do
shared_examples 'succesfully creates feature flag' do
before do
visit(new_project_feature_flag_path(project))
set_feature_flag_info('ci_live_trace', 'For live trace')
click_button 'Create feature flag'
expect(page).to have_current_path(project_feature_flags_path(project))
end
before do
visit(new_project_feature_flag_path(project))
set_feature_flag_info('ci_live_trace', 'For live trace')
click_button 'Create feature flag'
expect(page).to have_current_path(project_feature_flags_path(project))
end
it 'shows the created feature flag' do
within_feature_flag_row(1) do
expect(page.find('.feature-flag-name')).to have_content('ci_live_trace')
expect(page).to have_css('.js-feature-flag-status .badge-success')
it 'shows the created feature flag' do
within_feature_flag_row(1) do
expect(page.find('.feature-flag-name')).to have_content('ci_live_trace')
expect(page).to have_css('.js-feature-flag-status .badge-success')
within_feature_flag_scopes do
expect(page.find('.badge:nth-child(1)')).to have_content('*')
expect(page.find('.badge:nth-child(1)')['class']).to include('badge-active')
end
within_feature_flag_scopes do
expect(page.find('.badge:nth-child(1)')).to have_content('*')
expect(page.find('.badge:nth-child(1)')['class']).to include('badge-active')
end
end
end
context 'when feature flag audit enabled' do
include_examples 'succesfully creates feature flag'
it 'records audit event' do
visit(project_audit_events_path(project))
it 'records audit event' do
visit(project_audit_events_path(project))
expect(page).to have_text("Created feature flag ci live trace with description \"For live trace\".")
end
end
context 'when feature flag audit is disabled' do
before do
stub_feature_flags(feature_flag_audit: false)
end
include_examples 'succesfully creates feature flag'
it 'does not record audit event' do
visit(project_audit_events_path(project))
expect(page).to have_no_text("Created feature flag")
end
expect(page).to have_text("Created feature flag ci live trace with description \"For live trace\".")
end
end
context 'when creates with disabling the default scope' do
shared_examples 'succesfully creates feature flag' do
before do
visit(new_project_feature_flag_path(project))
set_feature_flag_info('ci_live_trace', 'For live trace')
within_scope_row(1) do
within_status { find('.project-feature-toggle').click }
end
before do
visit(new_project_feature_flag_path(project))
set_feature_flag_info('ci_live_trace', 'For live trace')
click_button 'Create feature flag'
within_scope_row(1) do
within_status { find('.project-feature-toggle').click }
end
it 'shows the created feature flag' do
within_feature_flag_row(1) do
expect(page.find('.feature-flag-name')).to have_content('ci_live_trace')
expect(page).to have_css('.js-feature-flag-status .badge-danger')
within_feature_flag_scopes do
expect(page.find('.badge:nth-child(1)')).to have_content('*')
expect(page.find('.badge:nth-child(1)')['class']).to include('badge-inactive')
end
end
end
click_button 'Create feature flag'
end
context 'when feature flag audit enabled' do
include_examples 'succesfully creates feature flag'
end
it 'shows the created feature flag' do
within_feature_flag_row(1) do
expect(page.find('.feature-flag-name')).to have_content('ci_live_trace')
expect(page).to have_css('.js-feature-flag-status .badge-danger')
context 'when feature flag audit is disabled' do
before do
stub_feature_flags(feature_flag_audit: false)
within_feature_flag_scopes do
expect(page.find('.badge:nth-child(1)')).to have_content('*')
expect(page.find('.badge:nth-child(1)')['class']).to include('badge-inactive')
end
end
include_examples 'succesfully creates feature flag'
end
end
context 'when creates with an additional scope' do
shared_examples 'succesfully creates feature flag' do
before do
visit(new_project_feature_flag_path(project))
set_feature_flag_info('mr_train', '')
within_scope_row(2) do
within_environment_spec do
find('.js-env-input').set("review/*")
find('.js-create-button').click
end
end
within_scope_row(2) do
within_status { find('.project-feature-toggle').click }
before do
visit(new_project_feature_flag_path(project))
set_feature_flag_info('mr_train', '')
within_scope_row(2) do
within_environment_spec do
find('.js-env-input').set("review/*")
find('.js-create-button').click
end
click_button 'Create feature flag'
end
it 'shows the created feature flag' do
within_feature_flag_row(1) do
expect(page.find('.feature-flag-name')).to have_content('mr_train')
expect(page).to have_css('.js-feature-flag-status .badge-success')
within_feature_flag_scopes do
expect(page.find('.badge:nth-child(1)')).to have_content('*')
expect(page.find('.badge:nth-child(1)')['class']).to include('badge-active')
expect(page.find('.badge:nth-child(2)')).to have_content('review/*')
expect(page.find('.badge:nth-child(2)')['class']).to include('badge-active')
end
end
within_scope_row(2) do
within_status { find('.project-feature-toggle').click }
end
end
context 'when feature flag audit enabled' do
include_examples 'succesfully creates feature flag'
click_button 'Create feature flag'
end
context 'when feature flag audit is disabled' do
before do
stub_feature_flags(feature_flag_audit: false)
end
it 'shows the created feature flag' do
within_feature_flag_row(1) do
expect(page.find('.feature-flag-name')).to have_content('mr_train')
expect(page).to have_css('.js-feature-flag-status .badge-success')
include_examples 'succesfully creates feature flag'
within_feature_flag_scopes do
expect(page.find('.badge:nth-child(1)')).to have_content('*')
expect(page.find('.badge:nth-child(1)')['class']).to include('badge-active')
expect(page.find('.badge:nth-child(2)')).to have_content('review/*')
expect(page.find('.badge:nth-child(2)')['class']).to include('badge-active')
end
end
end
end
context 'when searches an environment name for scope creation' do
let!(:environment) { create(:environment, name: 'production', project: project) }
shared_examples 'succesfully creates feature flag' do
before do
visit(new_project_feature_flag_path(project))
set_feature_flag_info('mr_train', '')
before do
visit(new_project_feature_flag_path(project))
set_feature_flag_info('mr_train', '')
within_scope_row(2) do
within_environment_spec do
find('.js-env-input').set('prod')
click_button 'production'
end
within_scope_row(2) do
within_environment_spec do
find('.js-env-input').set('prod')
click_button 'production'
end
click_button 'Create feature flag'
end
it 'shows the created feature flag' do
within_feature_flag_row(1) do
expect(page.find('.feature-flag-name')).to have_content('mr_train')
expect(page).to have_css('.js-feature-flag-status .badge-success')
within_feature_flag_scopes do
expect(page.find('.badge:nth-child(1)')).to have_content('*')
expect(page.find('.badge:nth-child(1)')['class']).to include('badge-active')
expect(page.find('.badge:nth-child(2)')).to have_content('production')
expect(page.find('.badge:nth-child(2)')['class']).to include('badge-inactive')
end
end
end
click_button 'Create feature flag'
end
context 'when feature flag audit enabled' do
include_examples 'succesfully creates feature flag'
end
it 'shows the created feature flag' do
within_feature_flag_row(1) do
expect(page.find('.feature-flag-name')).to have_content('mr_train')
expect(page).to have_css('.js-feature-flag-status .badge-success')
context 'when feature flag audit is disabled' do
before do
stub_feature_flags(feature_flag_audit: false)
within_feature_flag_scopes do
expect(page.find('.badge:nth-child(1)')).to have_content('*')
expect(page.find('.badge:nth-child(1)')['class']).to include('badge-active')
expect(page.find('.badge:nth-child(2)')).to have_content('production')
expect(page.find('.badge:nth-child(2)')['class']).to include('badge-inactive')
end
end
include_examples 'succesfully creates feature flag'
end
end
......
......@@ -37,154 +37,94 @@ describe 'User updates feature flag', :js do
end
context 'when user updates a status of a scope' do
shared_examples 'succesfully updates feature flag' do
before do
within_scope_row(2) do
within_status { find('.project-feature-toggle').click }
end
click_button 'Save changes'
expect(page).to have_current_path(project_feature_flags_path(project))
before do
within_scope_row(2) do
within_status { find('.project-feature-toggle').click }
end
it 'shows the updated feature flag' do
within_feature_flag_row(1) do
expect(page.find('.feature-flag-name')).to have_content('ci_live_trace')
expect(page).to have_css('.js-feature-flag-status .badge-danger')
within_feature_flag_scopes do
expect(page.find('.badge:nth-child(1)')).to have_content('*')
expect(page.find('.badge:nth-child(1)')['class']).to include('badge-inactive')
expect(page.find('.badge:nth-child(2)')).to have_content('review/*')
expect(page.find('.badge:nth-child(2)')['class']).to include('badge-inactive')
end
end
end
click_button 'Save changes'
expect(page).to have_current_path(project_feature_flags_path(project))
end
context 'when feature flag audit enabled' do
include_examples 'succesfully updates feature flag'
it 'shows the updated feature flag' do
within_feature_flag_row(1) do
expect(page.find('.feature-flag-name')).to have_content('ci_live_trace')
expect(page).to have_css('.js-feature-flag-status .badge-danger')
it 'records audit event' do
visit(project_audit_events_path(project))
expect(page).to(
have_text("Updated feature flag ci live trace. Updated rule review/* active state from true to false.")
)
within_feature_flag_scopes do
expect(page.find('.badge:nth-child(1)')).to have_content('*')
expect(page.find('.badge:nth-child(1)')['class']).to include('badge-inactive')
expect(page.find('.badge:nth-child(2)')).to have_content('review/*')
expect(page.find('.badge:nth-child(2)')['class']).to include('badge-inactive')
end
end
end
context 'when feature flag audit is disabled' do
before do
stub_feature_flags(feature_flag_audit: false)
end
include_examples 'succesfully updates feature flag'
it 'records audit event' do
visit(project_audit_events_path(project))
it 'does not record audit event' do
visit(project_audit_events_path(project))
expect(page).to have_no_text("Updated feature flag")
end
expect(page).to(
have_text("Updated feature flag ci live trace. Updated rule review/* active state from true to false.")
)
end
end
context 'when user adds a new scope' do
shared_examples 'succesfully updates feature flag' do
before do
within_scope_row(3) do
within_environment_spec do
find('.js-env-input').set('production')
find('.js-create-button').click
end
before do
within_scope_row(3) do
within_environment_spec do
find('.js-env-input').set('production')
find('.js-create-button').click
end
click_button 'Save changes'
expect(page).to have_current_path(project_feature_flags_path(project))
end
it 'shows the newly created scope' do
within_feature_flag_row(1) do
within_feature_flag_scopes do
expect(page.find('.badge:nth-child(3)')).to have_content('production')
expect(page.find('.badge:nth-child(3)')['class']).to include('badge-inactive')
end
end
end
click_button 'Save changes'
expect(page).to have_current_path(project_feature_flags_path(project))
end
context 'when feature flag audit enabled' do
include_examples 'succesfully updates feature flag'
it 'records audit event' do
visit(project_audit_events_path(project))
expect(page).to(
have_text("Updated feature flag ci live trace")
)
it 'shows the newly created scope' do
within_feature_flag_row(1) do
within_feature_flag_scopes do
expect(page.find('.badge:nth-child(3)')).to have_content('production')
expect(page.find('.badge:nth-child(3)')['class']).to include('badge-inactive')
end
end
end
context 'when feature flag audit is disabled' do
before do
stub_feature_flags(feature_flag_audit: false)
end
include_examples 'succesfully updates feature flag'
it 'records audit event' do
visit(project_audit_events_path(project))
it 'does not record audit event' do
visit(project_audit_events_path(project))
expect(page).to have_no_text("Updated feature flag")
end
expect(page).to(
have_text("Updated feature flag ci live trace")
)
end
end
context 'when user deletes a scope' do
shared_examples 'succesfully updates feature flag' do
before do
within_scope_row(2) do
within_delete { find('.js-delete-scope').click }
end
click_button 'Save changes'
expect(page).to have_current_path(project_feature_flags_path(project))
before do
within_scope_row(2) do
within_delete { find('.js-delete-scope').click }
end
it 'shows the updated feature flag' do
within_feature_flag_row(1) do
within_feature_flag_scopes do
expect(page).to have_css('.badge:nth-child(1)')
expect(page).not_to have_css('.badge:nth-child(2)')
end
end
end
click_button 'Save changes'
expect(page).to have_current_path(project_feature_flags_path(project))
end
context 'when feature flag audit enabled' do
include_examples 'succesfully updates feature flag'
it 'records audit event' do
visit(project_audit_events_path(project))
expect(page).to(
have_text("Updated feature flag ci live trace")
)
it 'shows the updated feature flag' do
within_feature_flag_row(1) do
within_feature_flag_scopes do
expect(page).to have_css('.badge:nth-child(1)')
expect(page).not_to have_css('.badge:nth-child(2)')
end
end
end
context 'when feature flag audit is disabled' do
before do
stub_feature_flags(feature_flag_audit: false)
end
it 'records audit event' do
visit(project_audit_events_path(project))
include_examples 'succesfully updates feature flag'
it 'does not record audit event' do
visit(project_audit_events_path(project))
expect(page).to have_no_text("Updated feature flag")
end
expect(page).to(
have_text("Updated feature flag ci live trace")
)
end
end
end
......@@ -55,22 +55,6 @@ describe FeatureFlags::CreateService do
expect { subject }.to change { AuditEvent.count }.by(1)
expect(AuditEvent.last.present.action).to eq(expected_message)
end
context 'when feature flag audit is disabled' do
before do
stub_feature_flags(feature_flag_audit: false)
end
it { expect(subject[:status]).to eq(:success) }
it 'creates feature flag' do
expect { subject }.to change { Operations::FeatureFlag.count }.by(1)
end
it 'does not create audit log' do
expect { subject }.not_to change { AuditEvent.count }
end
end
end
end
end
......@@ -24,20 +24,6 @@ describe FeatureFlags::DestroyService do
expect(audit_event_message).to eq("Deleted feature flag <strong>#{feature_flag.name.tr('_', ' ')}</strong>.")
end
context 'when feature flag audit is disabled' do
before do
stub_feature_flags(feature_flag_audit: false)
end
it 'works successfully' do
expect(subject[:status]).to eq(:success)
end
it 'does not create audit event' do
expect { subject }.not_to change { AuditEvent.count }
end
end
context 'when feature flag can not be destroyed' do
before do
allow(feature_flag).to receive(:destroy).and_return(false)
......
......@@ -29,24 +29,6 @@ describe FeatureFlags::UpdateService do
)
end
shared_examples 'disabled feature flag audit' do
context 'when feature flag audit is disabled' do
before do
stub_feature_flags(feature_flag_audit: false)
end
it 'returns success status' do
expect(subject[:status]).to eq(:success)
end
it 'does not create audit event' do
expect { subject }.not_to change { AuditEvent.count }
end
end
end
include_examples 'disabled feature flag audit'
context 'with invalid params' do
let(:params) { { name: nil } }
......@@ -85,8 +67,6 @@ describe FeatureFlags::UpdateService do
" to <strong>\"new description\"</strong>.")
)
end
include_examples 'disabled feature flag audit'
end
context 'when active state is changed' do
......@@ -103,8 +83,6 @@ describe FeatureFlags::UpdateService do
"from <strong>true</strong> to <strong>false</strong>.")
)
end
include_examples 'disabled feature flag audit'
end
context 'when scope is renamed' do
......@@ -123,8 +101,6 @@ describe FeatureFlags::UpdateService do
)
end
include_examples 'disabled feature flag audit'
context 'when scope can not be updated' do
let(:params) do
{
......@@ -159,8 +135,6 @@ describe FeatureFlags::UpdateService do
expect(audit_event_message).to include("Deleted rule <strong>review</strong>.")
end
include_examples 'disabled feature flag audit'
context 'when scope can not be deleted' do
RSpec::Matchers.define_negated_matcher :not_change, :change
......@@ -191,8 +165,6 @@ describe FeatureFlags::UpdateService do
)
end
include_examples 'disabled feature flag audit'
context 'when scope can not be created' do
let(:new_environment_scope) { '' }
......
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