Module: RailsAuditLog::TestHelpers
- Defined in:
- lib/rails_audit_log/test_helpers.rb
Overview
Opt-in test helper for suppressing audit writes in test setup code.
Setup
# spec/rails_helper.rb
require "rails_audit_log/test_helpers"
RSpec.configure do |config|
config.include RailsAuditLog::TestHelpers
end
Usage
let(:post) { without_audit_log { Post.create!(title: "fixture") } }
Instance Method Summary collapse
-
#without_audit_log { ... } ⇒ Object
Executes the block with audit logging disabled.
Instance Method Details
#without_audit_log { ... } ⇒ Object
Executes the block with audit logging disabled. A prefix-free wrapper around RailsAuditLog.disable intended for use in FactoryBot factories, let blocks, and other test setup where audit noise is unwanted.
23 24 25 |
# File 'lib/rails_audit_log/test_helpers.rb', line 23 def without_audit_log(&block) RailsAuditLog.disable(&block) end |