paper_trail 5.2.3 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CONTRIBUTING.md +12 -20
- data/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +0 -8
- data/.travis.yml +7 -5
- data/Appraisals +8 -17
- data/CHANGELOG.md +46 -0
- data/README.md +47 -26
- data/doc/triage.md +27 -0
- data/gemfiles/{ar4.gemfile → ar_4.2.gemfile} +0 -0
- data/gemfiles/{ar5.gemfile → ar_5.0.gemfile} +0 -0
- data/gemfiles/ar_master.gemfile +9 -0
- data/lib/paper_trail/cleaner.rb +1 -1
- data/lib/paper_trail/config.rb +1 -15
- data/lib/paper_trail/frameworks/rails/controller.rb +1 -1
- data/lib/paper_trail/frameworks/rspec.rb +5 -0
- data/lib/paper_trail/has_paper_trail.rb +1 -292
- data/lib/paper_trail/model_config.rb +17 -7
- data/lib/paper_trail/record_history.rb +1 -9
- data/lib/paper_trail/record_trail.rb +148 -56
- data/lib/paper_trail/version_concern.rb +7 -7
- data/lib/paper_trail/version_number.rb +3 -3
- data/lib/paper_trail.rb +5 -14
- data/paper_trail.gemspec +2 -1
- data/spec/models/widget_spec.rb +16 -3
- data/test/dummy/app/models/song.rb +27 -22
- data/test/test_helper.rb +21 -23
- data/test/unit/associations_test.rb +1 -1
- data/test/unit/cleaner_test.rb +0 -37
- data/test/unit/inheritance_column_test.rb +2 -4
- data/test/unit/model_test.rb +56 -29
- data/test/unit/serializer_test.rb +11 -12
- data/test/unit/version_test.rb +0 -7
- metadata +10 -13
- data/gemfiles/ar3.gemfile +0 -19
- data/spec/models/fluxor_spec.rb +0 -17
- data/test/unit/timestamp_test.rb +0 -41
@@ -2,12 +2,19 @@ require "test_helper"
|
|
2
2
|
require "custom_json_serializer"
|
3
3
|
|
4
4
|
class SerializerTest < ActiveSupport::TestCase
|
5
|
+
extend CleanupCallbacks
|
6
|
+
|
7
|
+
cleanup_callbacks(Fluxor, :create)
|
8
|
+
cleanup_callbacks(Fluxor, :update)
|
9
|
+
cleanup_callbacks(Fluxor, :destroy)
|
10
|
+
cleanup_callbacks(Fluxor, :save)
|
11
|
+
|
12
|
+
setup do
|
13
|
+
Fluxor.instance_eval "has_paper_trail"
|
14
|
+
end
|
15
|
+
|
5
16
|
context "YAML Serializer" do
|
6
17
|
setup do
|
7
|
-
Fluxor.instance_eval <<-END
|
8
|
-
has_paper_trail
|
9
|
-
END
|
10
|
-
|
11
18
|
@fluxor = Fluxor.create name: "Some text."
|
12
19
|
|
13
20
|
# this is exactly what PaperTrail serializes
|
@@ -34,10 +41,6 @@ class SerializerTest < ActiveSupport::TestCase
|
|
34
41
|
config.serializer = PaperTrail::Serializers::JSON
|
35
42
|
end
|
36
43
|
|
37
|
-
Fluxor.instance_eval <<-END
|
38
|
-
has_paper_trail
|
39
|
-
END
|
40
|
-
|
41
44
|
@fluxor = Fluxor.create name: "Some text."
|
42
45
|
|
43
46
|
# this is exactly what PaperTrail serializes
|
@@ -77,10 +80,6 @@ class SerializerTest < ActiveSupport::TestCase
|
|
77
80
|
config.serializer = CustomJsonSerializer
|
78
81
|
end
|
79
82
|
|
80
|
-
Fluxor.instance_eval <<-END
|
81
|
-
has_paper_trail
|
82
|
-
END
|
83
|
-
|
84
83
|
@fluxor = Fluxor.create
|
85
84
|
|
86
85
|
# this is exactly what PaperTrail serializes
|
data/test/unit/version_test.rb
CHANGED
@@ -3,17 +3,10 @@ require "test_helper"
|
|
3
3
|
module PaperTrail
|
4
4
|
class VersionTest < ActiveSupport::TestCase
|
5
5
|
setup do
|
6
|
-
change_schema
|
7
6
|
@animal = Animal.create
|
8
7
|
assert Version.creates.present?
|
9
8
|
end
|
10
9
|
|
11
|
-
teardown do
|
12
|
-
restore_schema
|
13
|
-
Animal.connection.schema_cache.clear!
|
14
|
-
Animal.reset_column_information
|
15
|
-
end
|
16
|
-
|
17
10
|
context ".creates" do
|
18
11
|
should "return only create events" do
|
19
12
|
Version.creates.each do |version|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paper_trail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Stewart
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -17,20 +17,20 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '4.0'
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: '
|
23
|
+
version: '5.2'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
28
|
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: '
|
30
|
+
version: '4.0'
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '5.2'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: request_store
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -281,10 +281,11 @@ files:
|
|
281
281
|
- README.md
|
282
282
|
- Rakefile
|
283
283
|
- doc/bug_report_template.rb
|
284
|
+
- doc/triage.md
|
284
285
|
- doc/warning_about_not_setting_whodunnit.md
|
285
|
-
- gemfiles/
|
286
|
-
- gemfiles/
|
287
|
-
- gemfiles/
|
286
|
+
- gemfiles/ar_4.2.gemfile
|
287
|
+
- gemfiles/ar_5.0.gemfile
|
288
|
+
- gemfiles/ar_master.gemfile
|
288
289
|
- lib/generators/paper_trail/USAGE
|
289
290
|
- lib/generators/paper_trail/default_initializer.rb
|
290
291
|
- lib/generators/paper_trail/install_generator.rb
|
@@ -328,7 +329,6 @@ files:
|
|
328
329
|
- spec/models/callback_modifier_spec.rb
|
329
330
|
- spec/models/car_spec.rb
|
330
331
|
- spec/models/custom_primary_key_record_spec.rb
|
331
|
-
- spec/models/fluxor_spec.rb
|
332
332
|
- spec/models/gadget_spec.rb
|
333
333
|
- spec/models/joined_version_spec.rb
|
334
334
|
- spec/models/json_version_spec.rb
|
@@ -445,7 +445,6 @@ files:
|
|
445
445
|
- test/unit/serializers/mixin_json_test.rb
|
446
446
|
- test/unit/serializers/mixin_yaml_test.rb
|
447
447
|
- test/unit/serializers/yaml_test.rb
|
448
|
-
- test/unit/timestamp_test.rb
|
449
448
|
- test/unit/version_test.rb
|
450
449
|
homepage: https://github.com/airblade/paper_trail
|
451
450
|
licenses:
|
@@ -479,7 +478,6 @@ test_files:
|
|
479
478
|
- spec/models/callback_modifier_spec.rb
|
480
479
|
- spec/models/car_spec.rb
|
481
480
|
- spec/models/custom_primary_key_record_spec.rb
|
482
|
-
- spec/models/fluxor_spec.rb
|
483
481
|
- spec/models/gadget_spec.rb
|
484
482
|
- spec/models/joined_version_spec.rb
|
485
483
|
- spec/models/json_version_spec.rb
|
@@ -596,5 +594,4 @@ test_files:
|
|
596
594
|
- test/unit/serializers/mixin_json_test.rb
|
597
595
|
- test/unit/serializers/mixin_yaml_test.rb
|
598
596
|
- test/unit/serializers/yaml_test.rb
|
599
|
-
- test/unit/timestamp_test.rb
|
600
597
|
- test/unit/version_test.rb
|
data/gemfiles/ar3.gemfile
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "activerecord", "~> 3.2.22"
|
6
|
-
gem "i18n", "~> 0.6.11"
|
7
|
-
gem "request_store", "~> 1.1.0"
|
8
|
-
gem "sinatra", "~> 1.4.6"
|
9
|
-
|
10
|
-
group :development, :test do
|
11
|
-
gem "railties", "~> 3.2.22"
|
12
|
-
gem "test-unit", "~> 3.1.5"
|
13
|
-
|
14
|
-
platforms :ruby do
|
15
|
-
gem "mysql2", "~> 0.3.20"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
gemspec :path => "../"
|
data/spec/models/fluxor_spec.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require "rails_helper"
|
2
|
-
|
3
|
-
describe Fluxor, type: :model do
|
4
|
-
describe "`be_versioned` matcher" do
|
5
|
-
it { is_expected.to_not be_versioned }
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "Methods" do
|
9
|
-
describe "Class" do
|
10
|
-
describe ".paper_trail.enabled?" do
|
11
|
-
it "returns false" do
|
12
|
-
expect(Fluxor.paper_trail.enabled?).to eq(false)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/test/unit/timestamp_test.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class TimestampTest < ActiveSupport::TestCase
|
4
|
-
setup do
|
5
|
-
PaperTrail.timestamp_field = :custom_created_at
|
6
|
-
change_schema
|
7
|
-
|
8
|
-
Fluxor.instance_eval <<-END
|
9
|
-
has_paper_trail
|
10
|
-
END
|
11
|
-
|
12
|
-
@fluxor = Fluxor.create name: "Some text."
|
13
|
-
@fluxor.update_attributes name: "Some more text."
|
14
|
-
@fluxor.update_attributes name: "Even more text."
|
15
|
-
end
|
16
|
-
|
17
|
-
teardown do
|
18
|
-
PaperTrail.timestamp_field = :created_at
|
19
|
-
restore_schema
|
20
|
-
end
|
21
|
-
|
22
|
-
test "versions works with custom timestamp field" do
|
23
|
-
# Normal behaviour
|
24
|
-
assert_equal 3, @fluxor.versions.length
|
25
|
-
assert_nil @fluxor.versions[0].reify
|
26
|
-
assert_equal "Some text.", @fluxor.versions[1].reify.name
|
27
|
-
assert_equal "Some more text.", @fluxor.versions[2].reify.name
|
28
|
-
|
29
|
-
# Tinker with custom timestamps.
|
30
|
-
now = Time.now.utc
|
31
|
-
@fluxor.versions.reverse.each_with_index do |version, index|
|
32
|
-
version.update_attribute :custom_created_at, (now + index.seconds)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Test we are ordering by custom timestamps.
|
36
|
-
@fluxor.versions.reload # reload association
|
37
|
-
assert_nil @fluxor.versions[2].reify
|
38
|
-
assert_equal "Some text.", @fluxor.versions[1].reify.name
|
39
|
-
assert_equal "Some more text.", @fluxor.versions[0].reify.name
|
40
|
-
end
|
41
|
-
end
|