Commit a492145f authored by Andrew Fontaine's avatar Andrew Fontaine

Adjust Feature Flag Audit Test to be Flexible

It seems the ordering of the audit log message is not consistent, but we
can adjust the test slightly to be more adaptable to ordering changes.
It still asserts that the first line of the message is that the feature
flag is created with a description, but only ensures that the creation
of strategies is audited. The order is not considered.
parent c8a5ead0
......@@ -52,8 +52,7 @@ module FeatureFlags
scopes = strategy.scopes
.map { |scope| %Q("#{scope.environment_scope}") }
.join(', ')
%Q(Created strategy \"#{strategy.name}\" )\
"with scopes #{scopes}."
%Q(Created strategy "#{strategy.name}" with scopes #{scopes}.)
end
def feature_flag_by_name
......
......@@ -69,15 +69,10 @@ RSpec.describe FeatureFlags::CreateService do
end
it 'creates audit event' do
expected_message = 'Created feature flag feature_flag '\
'with description "description". '\
'Created strategy "default" with scopes '\
'"*". '\
'Created strategy "default" with scopes '\
'"production".'
expect { subject }.to change { AuditEvent.count }.by(1)
expect(AuditEvent.last.details[:custom_message]).to eq(expected_message)
expect(AuditEvent.last.details[:custom_message]).to start_with('Created feature flag feature_flag with description "description".')
expect(AuditEvent.last.details[:custom_message]).to include('Created strategy "default" with scopes "*".')
expect(AuditEvent.last.details[:custom_message]).to include('Created strategy "default" with scopes "production".')
end
context 'when user is reporter' do
......
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