changes_are_logged 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/CHANGELOG.md +3 -0
- data/changes_are_logged.gemspec +2 -2
- data/lib/changes_are_logged.rb +4 -3
- data/lib/changes_are_logged/version.rb +1 -1
- data/spec/change_log_spec.rb +5 -5
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce6f89495c02282666101bb8a64a7a9e1da9c6a3
|
4
|
+
data.tar.gz: 8233bfd6e2fc6efe463341fb2a0531dc2a0e50ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac02e46ccbb4ebe6608b7a156cdd4e5890faf9903dbdc2fac82ede1b6bc23a5bd6a20c5d632600c68c59119164ca61e0b60e17bae69205b0577081df9b58c715
|
7
|
+
data.tar.gz: 62dc644409c8078f9d8948dd89425b15f3b9c709bea0e3afd59bd0fc114756ab97fbbfe4891d1ce40534fb329c3796fa248e2c2af6994ef7bc562cda65deae8b
|
data/.travis.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
3
|
+
- 2.5.3
|
4
4
|
sudo: false
|
5
5
|
cache:
|
6
6
|
- bundler
|
@@ -8,7 +8,7 @@ notifications:
|
|
8
8
|
email: false
|
9
9
|
script: bundle exec rspec
|
10
10
|
env:
|
11
|
-
- RAILS_VERSION='~> 4.0.0'
|
12
|
-
- RAILS_VERSION='~> 4.1.0'
|
13
11
|
- RAILS_VERSION='~> 4.2.0'
|
14
|
-
- RAILS_VERSION='~> 5.0.
|
12
|
+
- RAILS_VERSION='~> 5.0.7'
|
13
|
+
- RAILS_VERSION='~> 5.1.7'
|
14
|
+
- RAILS_VERSION='~> 5.2.3
|
data/CHANGELOG.md
CHANGED
data/changes_are_logged.gemspec
CHANGED
@@ -15,9 +15,9 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
|
18
|
-
s.add_dependency 'activerecord', ENV.fetch('RAILS_VERSION', '>= 4.0')
|
18
|
+
s.add_dependency 'activerecord', ENV.fetch('RAILS_VERSION', '>= 4.0'), '< 6'
|
19
19
|
|
20
20
|
# specify any dependencies here instead of Gemfile:
|
21
21
|
s.add_development_dependency 'rspec-rails', '~> 3.0'
|
22
|
-
s.add_development_dependency 'sqlite3', '~> 1.3'
|
22
|
+
s.add_development_dependency 'sqlite3', '~> 1.3.6'
|
23
23
|
end
|
data/lib/changes_are_logged.rb
CHANGED
@@ -21,17 +21,18 @@ module ChangesAreLogged
|
|
21
21
|
@change_comments = "new record" if @change_comments.blank?
|
22
22
|
@changes_logged = {}
|
23
23
|
save_change_log
|
24
|
-
elsif changed? || !@change_comments.blank?
|
24
|
+
elsif (ActiveRecord::VERSION::STRING >= '5.1' ? saved_changes? : changed?) || !@change_comments.blank?
|
25
25
|
@changes_logged = HashWithIndifferentAccess.new
|
26
26
|
|
27
|
+
ar_version_changes = ActiveRecord::VERSION::STRING >= '5.1' ? saved_changes : changes
|
27
28
|
if log_changes_callback
|
28
|
-
|
29
|
+
ar_version_changes.each do |attribute, (old_value, new_value)|
|
29
30
|
@changes_logged[attribute] = log_changes_callback.call(
|
30
31
|
attribute, old_value, new_value
|
31
32
|
)
|
32
33
|
end
|
33
34
|
else
|
34
|
-
@changes_logged.merge!(
|
35
|
+
@changes_logged.merge!(ar_version_changes)
|
35
36
|
end
|
36
37
|
|
37
38
|
@changes_logged.delete("updated_at")
|
data/spec/change_log_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe 'ChangeLog' do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'should add an entry to the change_logs' do
|
12
|
-
@game.reload.change_logs.size.
|
12
|
+
expect(@game.reload.change_logs.size).to eq(@original_change_logs_size + 1)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -75,7 +75,7 @@ describe 'ChangeLog' do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'should not log anything' do
|
78
|
-
@game.reload.change_logs.size.
|
78
|
+
expect(@game.reload.change_logs.size).to eq(@original_change_logs_size)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -88,9 +88,9 @@ describe 'ChangeLog' do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'should log the comment and indicate no changes' do
|
91
|
-
@game.reload.change_logs.size.
|
92
|
-
@game.change_logs.last.changes_logged.
|
93
|
-
@game.change_logs.last.comments.
|
91
|
+
expect(@game.reload.change_logs.size).to eq(@original_change_logs_size + 1)
|
92
|
+
expect(@game.change_logs.last.changes_logged).to eq({})
|
93
|
+
expect(@game.change_logs.last.comments).to eq("commenting on a non-change")
|
94
94
|
end
|
95
95
|
end
|
96
96
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: changes_are_logged
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lawrence Wang
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-05-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -18,6 +18,9 @@ dependencies:
|
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '4.0'
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '6'
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -25,6 +28,9 @@ dependencies:
|
|
25
28
|
- - ">="
|
26
29
|
- !ruby/object:Gem::Version
|
27
30
|
version: '4.0'
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '6'
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: rspec-rails
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,14 +51,14 @@ dependencies:
|
|
45
51
|
requirements:
|
46
52
|
- - "~>"
|
47
53
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
54
|
+
version: 1.3.6
|
49
55
|
type: :development
|
50
56
|
prerelease: false
|
51
57
|
version_requirements: !ruby/object:Gem::Requirement
|
52
58
|
requirements:
|
53
59
|
- - "~>"
|
54
60
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
61
|
+
version: 1.3.6
|
56
62
|
description: Tracks changes to your activerecord models
|
57
63
|
email:
|
58
64
|
executables: []
|