Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/audit/auditor_spec.rb')
-rw-r--r--spec/lib/gitlab/audit/auditor_spec.rb30
1 files changed, 14 insertions, 16 deletions
diff --git a/spec/lib/gitlab/audit/auditor_spec.rb b/spec/lib/gitlab/audit/auditor_spec.rb
index 386d4157e90..bde72a656b8 100644
--- a/spec/lib/gitlab/audit/auditor_spec.rb
+++ b/spec/lib/gitlab/audit/auditor_spec.rb
@@ -25,35 +25,33 @@ RSpec.describe Gitlab::Audit::Auditor, feature_category: :audit_events do
describe '.audit' do
let(:audit!) { auditor.audit(context) }
+ before do
+ allow(Gitlab::Audit::Type::Definition).to receive(:defined?).and_call_original
+ allow(Gitlab::Audit::Type::Definition).to receive(:defined?).with(name).and_return(true)
+ end
+
context 'when yaml definition is not defined' do
before do
- allow(Gitlab::Audit::Type::Definition).to receive(:defined?).and_return(false)
- allow(Gitlab::AppLogger).to receive(:warn).and_return(app_logger)
+ allow(Gitlab::Audit::Type::Definition).to receive(:defined?).and_call_original
+ allow(Gitlab::Audit::Type::Definition).to receive(:defined?).with(name).and_return(false)
end
- it 'logs a warning when YAML is not defined' do
- expected_warning = {
- message: 'Logging audit events without an event type definition will be deprecated soon ' \
- '(https://docs.gitlab.com/ee/development/audit_event_guide/#event-type-definitions)',
- event_type: name
- }
-
- audit!
+ it 'raises an error' do
+ expected_error = "Audit event type YML file is not defined for audit_operation. " \
+ "Please read https://docs.gitlab.com/ee/development/audit_event_guide/" \
+ "#how-to-instrument-new-audit-events for adding a new audit event"
- expect(Gitlab::AppLogger).to have_received(:warn).with(expected_warning)
+ expect { audit! }.to raise_error(StandardError, expected_error)
end
end
context 'when yaml definition is defined' do
before do
allow(Gitlab::Audit::Type::Definition).to receive(:defined?).and_return(true)
- allow(Gitlab::AppLogger).to receive(:warn).and_return(app_logger)
end
- it 'does not log a warning when YAML is defined' do
- audit!
-
- expect(Gitlab::AppLogger).not_to have_received(:warn)
+ it 'does not raise an error' do
+ expect { audit! }.not_to raise_error
end
end