journaled 2.0.2 → 2.0.3
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 +2 -0
- data/app/models/concerns/journaled/changes.rb +33 -29
- data/config/initializers/change_protection.rb +4 -3
- data/lib/journaled/version.rb +1 -1
- data/spec/dummy/log/development.log +26 -15
- data/spec/dummy/log/test.log +1122 -8650
- data/spec/models/database_change_protection_spec.rb +74 -72
- metadata +3 -3
@@ -1,106 +1,108 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
if Rails::VERSION::MAJOR > 5 || (Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 2)
|
4
|
+
# rubocop:disable Rails/SkipsModelValidations
|
5
|
+
RSpec.describe "Raw database change protection" do
|
6
|
+
let(:journaled_class) do
|
7
|
+
Class.new(Delayed::Job) do
|
8
|
+
include Journaled::Changes
|
8
9
|
|
9
|
-
|
10
|
+
journal_changes_to :locked_at, as: :attempt
|
11
|
+
end
|
10
12
|
end
|
11
|
-
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
let(:journaled_class_with_no_journaled_columns) do
|
15
|
+
Class.new(Delayed::Job) do
|
16
|
+
include Journaled::Changes
|
17
|
+
end
|
16
18
|
end
|
17
|
-
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
describe "the relation" do
|
21
|
+
describe "#update_all" do
|
22
|
+
it "refuses on journaled columns" do
|
23
|
+
expect { journaled_class.update_all(locked_at: nil) }.to raise_error(/aborted by Journaled/)
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
it "succeeds on unjournaled columns" do
|
27
|
+
expect { journaled_class.update_all(handler: "") }.not_to raise_error
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
it "succeeds when forced on journaled columns" do
|
31
|
+
expect { journaled_class.update_all({ locked_at: nil }, force: true) }.not_to raise_error
|
32
|
+
end
|
31
33
|
end
|
32
|
-
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
describe "#delete" do
|
36
|
+
it "refuses if journaled columns exist" do
|
37
|
+
expect { journaled_class.delete(1) }.to raise_error(/aborted by Journaled/)
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
it "succeeds if no journaled columns exist" do
|
41
|
+
expect { journaled_class_with_no_journaled_columns.delete(1) }.not_to raise_error
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
it "succeeds if journaled columns exist when forced" do
|
45
|
+
expect { journaled_class.delete(1, force: true) }.not_to raise_error
|
46
|
+
end
|
45
47
|
end
|
46
|
-
end
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
describe "#delete_all" do
|
50
|
+
it "refuses if journaled columns exist" do
|
51
|
+
expect { journaled_class.delete_all }.to raise_error(/aborted by Journaled/)
|
52
|
+
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
it "succeeds if no journaled columns exist" do
|
55
|
+
expect { journaled_class_with_no_journaled_columns.delete_all }.not_to raise_error
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
58
|
+
it "succeeds if journaled columns exist when forced" do
|
59
|
+
expect { journaled_class.delete_all(force: true) }.not_to raise_error
|
60
|
+
end
|
59
61
|
end
|
60
62
|
end
|
61
|
-
end
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
describe "an instance" do
|
65
|
+
let(:job) do
|
66
|
+
module TestJob
|
67
|
+
def perform
|
68
|
+
"foo"
|
69
|
+
end
|
69
70
|
|
70
|
-
|
71
|
+
module_function :perform
|
72
|
+
end
|
71
73
|
end
|
72
|
-
end
|
73
74
|
|
74
|
-
|
75
|
+
subject { journaled_class.enqueue(job) }
|
75
76
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
describe "#update_columns" do
|
78
|
+
it "refuses on journaled columns" do
|
79
|
+
expect { subject.update_columns(locked_at: nil) }.to raise_error(/aborted by Journaled/)
|
80
|
+
end
|
80
81
|
|
81
|
-
|
82
|
-
|
83
|
-
|
82
|
+
it "succeeds on unjournaled columns" do
|
83
|
+
expect { subject.update_columns(handler: "") }.not_to raise_error
|
84
|
+
end
|
84
85
|
|
85
|
-
|
86
|
-
|
86
|
+
it "succeeds when forced on journaled columns" do
|
87
|
+
expect { subject.update_columns({ locked_at: nil }, force: true) }.not_to raise_error
|
88
|
+
end
|
87
89
|
end
|
88
|
-
end
|
89
90
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
91
|
+
describe "#delete" do
|
92
|
+
it "refuses if journaled columns exist" do
|
93
|
+
expect { subject.delete }.to raise_error(/aborted by Journaled/)
|
94
|
+
end
|
94
95
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
it "succeeds if no journaled columns exist" do
|
97
|
+
instance = journaled_class_with_no_journaled_columns.enqueue(job)
|
98
|
+
expect { instance.delete }.not_to raise_error
|
99
|
+
end
|
99
100
|
|
100
|
-
|
101
|
-
|
101
|
+
it "succeeds if journaled columns exist when forced" do
|
102
|
+
expect { subject.delete(force: true) }.not_to raise_error
|
103
|
+
end
|
102
104
|
end
|
103
105
|
end
|
104
106
|
end
|
107
|
+
# rubocop:enable Rails/SkipsModelValidations
|
105
108
|
end
|
106
|
-
# rubocop:enable Rails/SkipsModelValidations
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: journaled
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Lipson
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2019-
|
14
|
+
date: 2019-07-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: aws-sdk-resources
|
@@ -295,7 +295,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
295
295
|
- !ruby/object:Gem::Version
|
296
296
|
version: '0'
|
297
297
|
requirements: []
|
298
|
-
rubygems_version: 3.0.
|
298
|
+
rubygems_version: 3.0.3
|
299
299
|
signing_key:
|
300
300
|
specification_version: 4
|
301
301
|
summary: Journaling for Betterment apps.
|