simple_audit_trail 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +5 -6
- data/app/models/simple_audit_trail/audit.rb +3 -3
- data/db/migrate/20150512224022_create_simple_audit_trail_audits.rb +1 -1
- data/lib/simple_audit_trail.rb +17 -18
- data/lib/simple_audit_trail/engine.rb +2 -2
- data/lib/simple_audit_trail/version.rb +1 -1
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/models/mr_torque.rb +1 -1
- data/spec/dummy/app/models/tina.rb +1 -1
- data/spec/dummy/bin/bundle +1 -1
- data/spec/dummy/bin/rails +1 -1
- data/spec/dummy/bin/setup +8 -8
- data/spec/dummy/config/application.rb +7 -8
- data/spec/dummy/config/boot.rb +2 -2
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/db/schema.rb +22 -25
- data/spec/lib/simple_audit_trail_auditor_spec.rb +45 -45
- data/spec/models/simple_audit_trail/audit_spec.rb +5 -5
- data/spec/spec_helper.rb +3 -3
- metadata +8 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 25f363c3c75212ef5c5ed6f5727be96ceda69546
|
|
4
|
+
data.tar.gz: 48f94ac1a3dc881ebec6ec43aca0e772067f0f88
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0f571b1ea8734e335070544e055d13ae7c555c0a94b1f7e2f8dcedefab54f964e8f62f55175bfcba18a776f7c9c32ca6fa771c17e90dc279cae35cf50bae7633
|
|
7
|
+
data.tar.gz: 6348645e627166656460637539baaef270069b4559cdafdaec9b2363c1713844b6242ec0342d9b3b0124219b223b03e2aaa2b21d5706e9ca1ccaf32eba194ac2
|
data/Rakefile
CHANGED
|
@@ -5,13 +5,12 @@ rescue LoadError
|
|
|
5
5
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
|
8
|
+
APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
|
|
10
9
|
load 'rails/tasks/engine.rake'
|
|
11
10
|
Bundler::GemHelper.install_tasks
|
|
12
|
-
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
|
11
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each { |f| load f }
|
|
13
12
|
require 'rspec/core'
|
|
14
13
|
require 'rspec/core/rake_task'
|
|
15
|
-
desc
|
|
16
|
-
RSpec::Core::RakeTask.new(:
|
|
17
|
-
task :
|
|
14
|
+
desc 'Run all specs in spec directory (excluding plugin specs)'
|
|
15
|
+
RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
|
|
16
|
+
task default: :spec
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
module SimpleAuditTrail
|
|
2
2
|
class Audit < ActiveRecord::Base
|
|
3
|
-
belongs_to :simple_audit_trailable, :
|
|
3
|
+
belongs_to :simple_audit_trailable, polymorphic: true
|
|
4
4
|
def self.table_name
|
|
5
|
-
|
|
5
|
+
'simple_audit_trail_audits'
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
before_save :set_location_fields
|
|
9
9
|
|
|
10
10
|
def set_location_fields
|
|
11
11
|
self.trace ||= caller.select do |entry|
|
|
12
|
-
|
|
12
|
+
entry !~ /#{__FILE__}/ && (entry[0] != '/' || entry =~ /#{Rails.root}\/[^b]/)
|
|
13
13
|
end.join("\n")
|
|
14
14
|
match = trace.match(/(\w+)_controller.rb.*`(\w+)'/)
|
|
15
15
|
c, a = match && match[1..-1]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
class CreateSimpleAuditTrailAudits < ActiveRecord::Migration
|
|
2
2
|
def change
|
|
3
3
|
create_table :simple_audit_trail_audits do |t|
|
|
4
|
-
t.references :simple_audit_trailable, :
|
|
4
|
+
t.references :simple_audit_trailable, polymorphic: true
|
|
5
5
|
|
|
6
6
|
t.integer :who_id
|
|
7
7
|
t.text :from
|
data/lib/simple_audit_trail.rb
CHANGED
|
@@ -10,30 +10,30 @@ module SimpleAuditTrail
|
|
|
10
10
|
self.audited_fields = fields.map(&:to_s)
|
|
11
11
|
|
|
12
12
|
cattr_accessor :audit_options
|
|
13
|
-
self.audit_options = { :
|
|
13
|
+
self.audit_options = { require_audited_user_id: true }.merge(options)
|
|
14
14
|
|
|
15
15
|
attr_accessor :audited_user_id
|
|
16
16
|
|
|
17
17
|
has_many :simple_audits,
|
|
18
|
-
:
|
|
19
|
-
:
|
|
20
|
-
:
|
|
18
|
+
as: :simple_audit_trailable,
|
|
19
|
+
class_name: 'SimpleAuditTrail::Audit',
|
|
20
|
+
autosave: true
|
|
21
21
|
|
|
22
22
|
after_create :save_all_audits
|
|
23
23
|
define_method :save_all_audits do
|
|
24
24
|
if audited_user_id.nil? && audit_options[:require_audited_user_id]
|
|
25
|
-
raise
|
|
25
|
+
raise 'audited setter method called without setting audited_user_id'
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
from = {}
|
|
29
|
-
to = Hash[audited_fields.map { |k| [k, send(k)] }
|
|
29
|
+
to = Hash[audited_fields.map { |k| [k, send(k)] }]
|
|
30
30
|
unchanged = {}
|
|
31
31
|
|
|
32
32
|
simple_audits.create(
|
|
33
|
-
:
|
|
34
|
-
:
|
|
35
|
-
:
|
|
36
|
-
:
|
|
33
|
+
from: from.to_json,
|
|
34
|
+
to: to.to_json,
|
|
35
|
+
unchanged: unchanged.to_json,
|
|
36
|
+
who_id: audited_user_id
|
|
37
37
|
)
|
|
38
38
|
end
|
|
39
39
|
|
|
@@ -43,12 +43,11 @@ module SimpleAuditTrail
|
|
|
43
43
|
|
|
44
44
|
if changed_audited_fields.present?
|
|
45
45
|
if audited_user_id.nil? && audit_options[:require_audited_user_id]
|
|
46
|
-
raise
|
|
46
|
+
raise 'audited setter method called without setting audited_user_id'
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
to = Hash[changed_audited_fields.map { |k, v| [k, v[1]] } ]
|
|
49
|
+
from = Hash[changed_audited_fields.map { |k, v| [k, v[0]] }]
|
|
50
|
+
to = Hash[changed_audited_fields.map { |k, v| [k, v[1]] }]
|
|
52
51
|
unchanged = Hash[
|
|
53
52
|
(audited_fields - changed_audited_fields.keys).map do |f|
|
|
54
53
|
[f, send(f)]
|
|
@@ -56,10 +55,10 @@ module SimpleAuditTrail
|
|
|
56
55
|
]
|
|
57
56
|
|
|
58
57
|
simple_audits.create(
|
|
59
|
-
:
|
|
60
|
-
:
|
|
61
|
-
:
|
|
62
|
-
:
|
|
58
|
+
from: from.to_json,
|
|
59
|
+
to: to.to_json,
|
|
60
|
+
unchanged: unchanged.to_json,
|
|
61
|
+
who_id: audited_user_id
|
|
63
62
|
)
|
|
64
63
|
end
|
|
65
64
|
end
|
|
@@ -3,8 +3,8 @@ require 'simple_audit_trail'
|
|
|
3
3
|
module SimpleAuditTrail
|
|
4
4
|
class Engine < ::Rails::Engine
|
|
5
5
|
config.generators do |g|
|
|
6
|
-
g.test_framework :rspec, :
|
|
7
|
-
g.fixture_replacement :factory_girl, :
|
|
6
|
+
g.test_framework :rspec, fixture: false
|
|
7
|
+
g.fixture_replacement :factory_girl, dir: 'spec/factories'
|
|
8
8
|
g.assets false
|
|
9
9
|
g.helper false
|
|
10
10
|
end
|
data/spec/dummy/Rakefile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
|
2
2
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
|
3
3
|
|
|
4
|
-
require File.expand_path('
|
|
4
|
+
require File.expand_path('config/application', __dir__)
|
|
5
5
|
|
|
6
6
|
Rails.application.load_tasks
|
data/spec/dummy/bin/bundle
CHANGED
data/spec/dummy/bin/rails
CHANGED
data/spec/dummy/bin/setup
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
require 'pathname'
|
|
3
3
|
|
|
4
4
|
# path to your application root.
|
|
5
|
-
APP_ROOT = Pathname.new File.expand_path('
|
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('..', __dir__)
|
|
6
6
|
|
|
7
7
|
Dir.chdir APP_ROOT do
|
|
8
8
|
# This script is a starting point to setup your application.
|
|
9
9
|
# Add necessary setup steps to this file:
|
|
10
10
|
|
|
11
|
-
puts
|
|
12
|
-
system
|
|
13
|
-
system
|
|
11
|
+
puts '== Installing dependencies =='
|
|
12
|
+
system 'gem install bundler --conservative'
|
|
13
|
+
system 'bundle check || bundle install'
|
|
14
14
|
|
|
15
15
|
# puts "\n== Copying sample files =="
|
|
16
16
|
# unless File.exist?("config/database.yml")
|
|
@@ -18,12 +18,12 @@ Dir.chdir APP_ROOT do
|
|
|
18
18
|
# end
|
|
19
19
|
|
|
20
20
|
puts "\n== Preparing database =="
|
|
21
|
-
system
|
|
21
|
+
system 'bin/rake db:setup'
|
|
22
22
|
|
|
23
23
|
puts "\n== Removing old logs and tempfiles =="
|
|
24
|
-
system
|
|
25
|
-
system
|
|
24
|
+
system 'rm -f log/*'
|
|
25
|
+
system 'rm -rf tmp/cache'
|
|
26
26
|
|
|
27
27
|
puts "\n== Restarting application server =="
|
|
28
|
-
system
|
|
28
|
+
system 'touch tmp/restart.txt'
|
|
29
29
|
end
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
require File.expand_path('
|
|
1
|
+
require File.expand_path('boot', __dir__)
|
|
2
2
|
|
|
3
3
|
# Pick the frameworks you want:
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
7
|
-
require
|
|
8
|
-
require
|
|
4
|
+
require 'active_record/railtie'
|
|
5
|
+
require 'action_controller/railtie'
|
|
6
|
+
require 'action_mailer/railtie'
|
|
7
|
+
require 'action_view/railtie'
|
|
8
|
+
require 'sprockets/railtie'
|
|
9
9
|
# require "rails/test_unit/railtie"
|
|
10
10
|
|
|
11
11
|
Bundler.require(*Rails.groups)
|
|
12
|
-
require
|
|
12
|
+
require 'simple_audit_trail'
|
|
13
13
|
|
|
14
14
|
module Dummy
|
|
15
15
|
class Application < Rails::Application
|
|
@@ -29,4 +29,3 @@ module Dummy
|
|
|
29
29
|
config.active_record.raise_in_transactional_callbacks = true
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
|
-
|
data/spec/dummy/config/boot.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Set up gems listed in the Gemfile.
|
|
2
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('
|
|
2
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
|
|
3
3
|
|
|
4
4
|
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
|
5
|
-
$LOAD_PATH.unshift File.expand_path('
|
|
5
|
+
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
|
data/spec/dummy/db/schema.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
1
|
# This file is auto-generated from the current state of the database. Instead
|
|
3
2
|
# of editing this file, please use the migrations feature of Active Record to
|
|
4
3
|
# incrementally modify your database, and then regenerate this schema definition.
|
|
@@ -12,33 +11,31 @@
|
|
|
12
11
|
# It's strongly recommended that you check this file into your version control system.
|
|
13
12
|
|
|
14
13
|
ActiveRecord::Schema.define(version: 20170505201829) do
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
t.
|
|
18
|
-
t.datetime
|
|
19
|
-
t.datetime "updated_at", null: false
|
|
14
|
+
create_table 'mr_torques', force: :cascade do |t|
|
|
15
|
+
t.string 'todays_quote', limit: 255
|
|
16
|
+
t.datetime 'created_at', null: false
|
|
17
|
+
t.datetime 'updated_at', null: false
|
|
20
18
|
end
|
|
21
19
|
|
|
22
|
-
create_table
|
|
23
|
-
t.integer
|
|
24
|
-
t.string
|
|
25
|
-
t.integer
|
|
26
|
-
t.text
|
|
27
|
-
t.text
|
|
28
|
-
t.datetime
|
|
29
|
-
t.datetime
|
|
30
|
-
t.text
|
|
31
|
-
t.text
|
|
32
|
-
t.text
|
|
33
|
-
t.text
|
|
20
|
+
create_table 'simple_audit_trail_audits', force: :cascade do |t|
|
|
21
|
+
t.integer 'simple_audit_trailable_id'
|
|
22
|
+
t.string 'simple_audit_trailable_type', limit: 255
|
|
23
|
+
t.integer 'who_id'
|
|
24
|
+
t.text 'from'
|
|
25
|
+
t.text 'to'
|
|
26
|
+
t.datetime 'created_at', null: false
|
|
27
|
+
t.datetime 'updated_at', null: false
|
|
28
|
+
t.text 'unchanged'
|
|
29
|
+
t.text 'trace'
|
|
30
|
+
t.text 'controller'
|
|
31
|
+
t.text 'action'
|
|
34
32
|
end
|
|
35
33
|
|
|
36
|
-
create_table
|
|
37
|
-
t.integer
|
|
38
|
-
t.integer
|
|
39
|
-
t.string
|
|
40
|
-
t.datetime
|
|
41
|
-
t.datetime
|
|
34
|
+
create_table 'tinas', force: :cascade do |t|
|
|
35
|
+
t.integer 'ladies'
|
|
36
|
+
t.integer 'badonkadonks'
|
|
37
|
+
t.string 'mushy_snugglebites', limit: 255
|
|
38
|
+
t.datetime 'created_at', null: false
|
|
39
|
+
t.datetime 'updated_at', null: false
|
|
42
40
|
end
|
|
43
|
-
|
|
44
41
|
end
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe SimpleAuditTrail::Auditor do
|
|
4
|
-
it
|
|
4
|
+
it 'adds audit method to ActiveRecord::Base' do
|
|
5
5
|
expect(ActiveRecord::Base).to respond_to(:audit)
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
describe
|
|
9
|
-
it
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
describe 'audited model' do
|
|
9
|
+
it 'can call #audit' do
|
|
10
|
+
expect {
|
|
11
|
+
Tina.create(badonkadonks: 2, ladies: 1, audited_user_id: 123)
|
|
12
|
+
}.to_not raise_error
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
it
|
|
16
|
-
t = Tina.create(:
|
|
15
|
+
it 'has an audited_fields attribute' do
|
|
16
|
+
t = Tina.create(badonkadonks: 2, ladies: 1, audited_user_id: 123)
|
|
17
17
|
|
|
18
|
-
expect(t.audited_fields).to match_array([
|
|
18
|
+
expect(t.audited_fields).to match_array(%w[badonkadonks ladies])
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
context
|
|
21
|
+
context '#save' do
|
|
22
22
|
before do
|
|
23
23
|
@tina = Tina.create(
|
|
24
|
-
:
|
|
25
|
-
:
|
|
26
|
-
:
|
|
24
|
+
badonkadonks: 0,
|
|
25
|
+
ladies: 0,
|
|
26
|
+
audited_user_id: 123
|
|
27
27
|
)
|
|
28
28
|
@tina.reload
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
context
|
|
32
|
-
context
|
|
31
|
+
context 'when not configured to ignore user' do
|
|
32
|
+
context 'when all audited fields have changed' do
|
|
33
33
|
before do
|
|
34
34
|
@tina.badonkadonks = 1
|
|
35
35
|
@tina.ladies = 1
|
|
@@ -38,42 +38,42 @@ describe SimpleAuditTrail::Auditor do
|
|
|
38
38
|
@tina.audited_user_id = 123
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
it
|
|
41
|
+
it 'creates a SimpleAuditTrail::Audit record' do
|
|
42
42
|
expect {
|
|
43
43
|
@tina.save
|
|
44
44
|
}.to change(SimpleAuditTrail::Audit, :count).by(1)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
context
|
|
47
|
+
context 'the newly created simple_audits record' do
|
|
48
48
|
before do
|
|
49
49
|
@tina.save
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
it
|
|
52
|
+
it 'is an instance of SimpleAuditTrail::Audit' do
|
|
53
53
|
expect(@tina.simple_audits.last).to be_kind_of SimpleAuditTrail::Audit
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
it
|
|
57
|
-
expect(JSON.parse(@tina.simple_audits.last.from))
|
|
58
|
-
to eq JSON.parse(
|
|
56
|
+
it 'has a json hash for what the audited values were' do
|
|
57
|
+
expect(JSON.parse(@tina.simple_audits.last.from))
|
|
58
|
+
.to eq JSON.parse('{"ladies":0,"badonkadonks":0}')
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
it
|
|
62
|
-
expect(JSON.parse(@tina.simple_audits.last.to))
|
|
63
|
-
to eq JSON.parse(
|
|
61
|
+
it 'has a json hash for what the audited values are' do
|
|
62
|
+
expect(JSON.parse(@tina.simple_audits.last.to))
|
|
63
|
+
.to eq JSON.parse('{"ladies":1,"badonkadonks":1}')
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
it
|
|
66
|
+
it 'has a who_id for the user who made the change' do
|
|
67
67
|
expect(@tina.simple_audits.last.who_id).to eq 123
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
it
|
|
70
|
+
it 'has an empty unchanged value' do
|
|
71
71
|
expect(JSON.parse(@tina.simple_audits.last.unchanged)).to be_empty
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
context
|
|
76
|
+
context 'when some but not all audited fields have changed then' do
|
|
77
77
|
before do
|
|
78
78
|
@tina.badonkadonks = 1
|
|
79
79
|
|
|
@@ -82,23 +82,23 @@ describe SimpleAuditTrail::Auditor do
|
|
|
82
82
|
@tina.save
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
it
|
|
86
|
-
expect(JSON.parse(@tina.simple_audits.last.from))
|
|
87
|
-
to eq JSON.parse(
|
|
85
|
+
it 'has a json hash in `from` for what the changed audited values were' do
|
|
86
|
+
expect(JSON.parse(@tina.simple_audits.last.from))
|
|
87
|
+
.to eq JSON.parse('{"badonkadonks":0}')
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
-
it
|
|
91
|
-
expect(JSON.parse(@tina.simple_audits.last.to))
|
|
92
|
-
to eq JSON.parse(
|
|
90
|
+
it 'has a json hash in `to` for what the changed audited values are' do
|
|
91
|
+
expect(JSON.parse(@tina.simple_audits.last.to))
|
|
92
|
+
.to eq JSON.parse('{"badonkadonks":1}')
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
-
it
|
|
96
|
-
expect(JSON.parse(@tina.simple_audits.last.unchanged))
|
|
97
|
-
to eq JSON.parse(
|
|
95
|
+
it 'has a json hash in `unchanged` for what the unmodified audited values are' do
|
|
96
|
+
expect(JSON.parse(@tina.simple_audits.last.unchanged))
|
|
97
|
+
.to eq JSON.parse('{"ladies":0}')
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
context
|
|
101
|
+
context 'when audited fields have not changed' do
|
|
102
102
|
before do
|
|
103
103
|
@tina.mushy_snugglebites = "
|
|
104
104
|
That's Mushy Snugglebites' badonkadonk. She's my main squeeze.
|
|
@@ -106,28 +106,28 @@ describe SimpleAuditTrail::Auditor do
|
|
|
106
106
|
"
|
|
107
107
|
end
|
|
108
108
|
|
|
109
|
-
it
|
|
109
|
+
it 'does not raise an Exception even if no auditor is set' do
|
|
110
110
|
@tina.audited_user_id = nil
|
|
111
111
|
expect { @tina.save }.to_not raise_error
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
-
it
|
|
115
|
-
expect{
|
|
114
|
+
it 'does not create a SimpleAuditTrail::Audit record' do
|
|
115
|
+
expect {
|
|
116
116
|
@tina.save
|
|
117
117
|
}.to_not change(SimpleAuditTrail::Audit, :count)
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
121
|
|
|
122
|
-
context
|
|
122
|
+
context 'when configured to ignore user' do
|
|
123
123
|
before do
|
|
124
124
|
@torque = MrTorque.create(
|
|
125
|
-
:
|
|
125
|
+
todays_quote: 'THAT SENTENCE HAD TOO MANY SYLLABLES! APOLOGIZE!'
|
|
126
126
|
)
|
|
127
127
|
@torque.reload
|
|
128
128
|
end
|
|
129
129
|
|
|
130
|
-
it
|
|
130
|
+
it 'does not raise errors when audit_user_id is empty' do
|
|
131
131
|
@torque.todays_quote =
|
|
132
132
|
"Right now, you're ranked fifty in the badass leaderboards,
|
|
133
133
|
which puts you behind my grandma but ahead of a guy she gummed to
|
|
@@ -136,7 +136,7 @@ describe SimpleAuditTrail::Auditor do
|
|
|
136
136
|
@torque.save
|
|
137
137
|
}.to_not raise_error
|
|
138
138
|
end
|
|
139
|
-
it
|
|
139
|
+
it 'does not raise errors when audit_user_id is not empty' do
|
|
140
140
|
@torque.todays_quote =
|
|
141
141
|
"If you're still alive, grab some ammo. If you're not,
|
|
142
142
|
THIS MESSAGE IS IRRELEVANT!"
|
|
@@ -146,7 +146,7 @@ describe SimpleAuditTrail::Auditor do
|
|
|
146
146
|
}.to_not raise_error
|
|
147
147
|
end
|
|
148
148
|
|
|
149
|
-
it
|
|
149
|
+
it 'creates a SimpleAuditTrail::Audit record' do
|
|
150
150
|
@torque.todays_quote =
|
|
151
151
|
"If you're still alive, grab some ammo. If you're not,
|
|
152
152
|
THIS MESSAGE IS IRRELEVANT!"
|
|
@@ -3,13 +3,13 @@ require_relative '../../spec_helper'
|
|
|
3
3
|
describe SimpleAuditTrail::Audit do
|
|
4
4
|
before do
|
|
5
5
|
@audit = SimpleAuditTrail::Audit.new(
|
|
6
|
-
:
|
|
7
|
-
:
|
|
8
|
-
:
|
|
6
|
+
from: { badonkadonks: 20 }.to_json,
|
|
7
|
+
to: { badonkadonks: 21 }.to_json,
|
|
8
|
+
who_id: 29
|
|
9
|
+
)
|
|
9
10
|
end
|
|
10
11
|
|
|
11
|
-
it
|
|
12
|
+
it 'can be instantiated' do
|
|
12
13
|
expect(@audit).to be_kind_of SimpleAuditTrail::Audit
|
|
13
14
|
end
|
|
14
|
-
|
|
15
15
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
ENV['RAILS_ENV'] ||= 'test'
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
3
|
+
require_relative 'dummy/config/environment'
|
|
4
4
|
|
|
5
5
|
require 'rspec/rails'
|
|
6
|
-
require '
|
|
6
|
+
require 'factory_bot_rails'
|
|
7
7
|
require 'database_cleaner'
|
|
8
8
|
require 'byebug'
|
|
9
9
|
|
|
@@ -17,7 +17,7 @@ RSpec.configure do |config|
|
|
|
17
17
|
|
|
18
18
|
config.infer_base_class_for_anonymous_controllers = false
|
|
19
19
|
|
|
20
|
-
config.order =
|
|
20
|
+
config.order = 'random'
|
|
21
21
|
|
|
22
22
|
config.use_transactional_fixtures = false
|
|
23
23
|
|
metadata
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simple_audit_trail
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Christopher Maujean
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-09-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - ~>
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '4'
|
|
20
17
|
- - '>='
|
|
21
18
|
- !ruby/object:Gem::Version
|
|
22
19
|
version: 4.0.0
|
|
@@ -24,14 +21,11 @@ dependencies:
|
|
|
24
21
|
prerelease: false
|
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
23
|
requirements:
|
|
27
|
-
- - ~>
|
|
28
|
-
- !ruby/object:Gem::Version
|
|
29
|
-
version: '4'
|
|
30
24
|
- - '>='
|
|
31
25
|
- !ruby/object:Gem::Version
|
|
32
26
|
version: 4.0.0
|
|
33
27
|
- !ruby/object:Gem::Dependency
|
|
34
|
-
name:
|
|
28
|
+
name: byebug
|
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
|
36
30
|
requirements:
|
|
37
31
|
- - '>='
|
|
@@ -45,7 +39,7 @@ dependencies:
|
|
|
45
39
|
- !ruby/object:Gem::Version
|
|
46
40
|
version: '0'
|
|
47
41
|
- !ruby/object:Gem::Dependency
|
|
48
|
-
name:
|
|
42
|
+
name: capybara
|
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
|
50
44
|
requirements:
|
|
51
45
|
- - '>='
|
|
@@ -59,7 +53,7 @@ dependencies:
|
|
|
59
53
|
- !ruby/object:Gem::Version
|
|
60
54
|
version: '0'
|
|
61
55
|
- !ruby/object:Gem::Dependency
|
|
62
|
-
name:
|
|
56
|
+
name: database_cleaner
|
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
|
64
58
|
requirements:
|
|
65
59
|
- - '>='
|
|
@@ -73,7 +67,7 @@ dependencies:
|
|
|
73
67
|
- !ruby/object:Gem::Version
|
|
74
68
|
version: '0'
|
|
75
69
|
- !ruby/object:Gem::Dependency
|
|
76
|
-
name:
|
|
70
|
+
name: factory_bot_rails
|
|
77
71
|
requirement: !ruby/object:Gem::Requirement
|
|
78
72
|
requirements:
|
|
79
73
|
- - '>='
|
|
@@ -87,7 +81,7 @@ dependencies:
|
|
|
87
81
|
- !ruby/object:Gem::Version
|
|
88
82
|
version: '0'
|
|
89
83
|
- !ruby/object:Gem::Dependency
|
|
90
|
-
name:
|
|
84
|
+
name: rspec-rails
|
|
91
85
|
requirement: !ruby/object:Gem::Requirement
|
|
92
86
|
requirements:
|
|
93
87
|
- - '>='
|
|
@@ -101,7 +95,7 @@ dependencies:
|
|
|
101
95
|
- !ruby/object:Gem::Version
|
|
102
96
|
version: '0'
|
|
103
97
|
- !ruby/object:Gem::Dependency
|
|
104
|
-
name:
|
|
98
|
+
name: sqlite3
|
|
105
99
|
requirement: !ruby/object:Gem::Requirement
|
|
106
100
|
requirements:
|
|
107
101
|
- - '>='
|