-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add paper_trail to reporters and bump version to 1.4.1
- Loading branch information
Showing
8 changed files
with
96 additions
and
11 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# 1.4.1 | ||
|
||
* Add paper_trail support | ||
|
||
# 1.4.0 | ||
|
||
* Set minimum ruby version requirement to 2.5.0 | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module ActionReporter | ||
class PaperTrailReporter < Base | ||
class_accessor "PaperTrail", gem_spec: "paper_trail (~> 15)" | ||
|
||
def notify(*) | ||
end | ||
|
||
def context(args) | ||
end | ||
|
||
def reset_context | ||
PaperTrail.request.whodunnit = nil | ||
end | ||
|
||
def audited_user | ||
PaperTrail.request.whodunnit | ||
end | ||
|
||
def audited_user=(user) | ||
PaperTrail.request.whodunnit = user | ||
end | ||
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
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,36 @@ | ||
require 'spec_helper' | ||
require 'rails' | ||
require 'paper_trail' | ||
|
||
RSpec.describe ActionReporter::PaperTrailReporter do | ||
subject(:instance) { described_class.new } | ||
|
||
describe '#notify' do | ||
|
||
end | ||
|
||
describe '#context' do | ||
|
||
end | ||
|
||
describe '#audited_user=' do | ||
subject(:audited_user=) { instance.audited_user = user } | ||
|
||
let(:user) { double('User', to_global_id: 'gid://user/1') } | ||
|
||
it 'sets audited_user' do | ||
expect(PaperTrail.request.whodunnit).to eq(nil) | ||
subject | ||
expect(PaperTrail.request.whodunnit).to eq(user) | ||
end | ||
end | ||
|
||
describe '#reset_context' do | ||
subject(:reset_context) { instance.reset_context } | ||
|
||
it 'resets context' do | ||
expect(PaperTrail.request).to receive(:whodunnit=).with(nil) | ||
subject | ||
end | ||
end | ||
end |