Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add audit trail events for team (#7285)
- Loading branch information
1 parent
cd28f40
commit 9ff5978
Showing
5 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,3 +54,5 @@ def push_event_data | |
} | ||
end | ||
end | ||
|
||
Team.include_mod_with('Audit::Team') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Enterprise::Audit::Team | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
audited associated_with: :account | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Team do | ||
let(:account) { create(:account) } | ||
let!(:team) { create(:team, account: account) } | ||
|
||
describe 'audit log' do | ||
context 'when team is created' do | ||
it 'has associated audit log created' do | ||
expect(Audited::Audit.where(auditable_type: 'Team', action: 'create').count).to eq 1 | ||
end | ||
end | ||
|
||
context 'when team is updated' do | ||
it 'has associated audit log created' do | ||
team.update(description: 'awesome team') | ||
expect(Audited::Audit.where(auditable_type: 'Team', action: 'update').count).to eq 1 | ||
end | ||
end | ||
|
||
context 'when team is deleted' do | ||
it 'has associated audit log created' do | ||
team.destroy! | ||
expect(Audited::Audit.where(auditable_type: 'Team', action: 'destroy').count).to eq 1 | ||
end | ||
end | ||
end | ||
end |