journaled 2.2.0 → 2.3.0
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/README.md +11 -0
- data/app/models/concerns/journaled/changes.rb +5 -5
- data/app/models/journaled/change.rb +3 -0
- data/app/models/journaled/change_writer.rb +1 -0
- data/app/models/journaled/event.rb +5 -2
- data/app/models/journaled/writer.rb +5 -5
- data/lib/journaled.rb +2 -2
- data/lib/journaled/enqueue.rb +13 -0
- data/lib/journaled/version.rb +1 -1
- data/spec/dummy/log/development.log +33 -22
- data/spec/dummy/log/test.log +14703 -1841
- data/spec/models/concerns/journaled/changes_spec.rb +11 -0
- data/spec/models/journaled/change_writer_spec.rb +5 -0
- data/spec/models/journaled/event_spec.rb +23 -16
- data/spec/models/journaled/writer_spec.rb +22 -9
- metadata +18 -4
- data/lib/journaled/job_priority.rb +0 -5
@@ -92,4 +92,15 @@ RSpec.describe Journaled::Changes do
|
|
92
92
|
expect(change_writer).to have_received(:delete)
|
93
93
|
expect(Journaled::ChangeWriter).to have_received(:new)
|
94
94
|
end
|
95
|
+
|
96
|
+
context 'when DJ opts are provided' do
|
97
|
+
before do
|
98
|
+
klass.journal_changes_to :thing, as: :other_thing, enqueue_with: { asdf: 1, foo: 'bar' }
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'sets them on the model' do
|
102
|
+
expect(klass.journaled_enqueue_opts).to eq(asdf: 1, foo: 'bar')
|
103
|
+
expect(klass.new.journaled_enqueue_opts).to eq(asdf: 1, foo: 'bar')
|
104
|
+
end
|
105
|
+
end
|
95
106
|
end
|
@@ -17,6 +17,7 @@ RSpec.describe Journaled::ChangeWriter do
|
|
17
17
|
"name" => %w(bill bob),
|
18
18
|
"last_sign_in_at" => now,
|
19
19
|
},
|
20
|
+
journaled_enqueue_opts: {},
|
20
21
|
)
|
21
22
|
end
|
22
23
|
|
@@ -61,6 +62,7 @@ RSpec.describe Journaled::ChangeWriter do
|
|
61
62
|
"last_sign_in_at" => Time.zone.now,
|
62
63
|
},
|
63
64
|
saved_changes: {},
|
65
|
+
journaled_enqueue_opts: {},
|
64
66
|
)
|
65
67
|
end
|
66
68
|
|
@@ -88,6 +90,7 @@ RSpec.describe Journaled::ChangeWriter do
|
|
88
90
|
changes: {
|
89
91
|
"name" => %w(bob bill),
|
90
92
|
},
|
93
|
+
journaled_enqueue_opts: {},
|
91
94
|
)
|
92
95
|
end
|
93
96
|
|
@@ -183,6 +186,7 @@ RSpec.describe Journaled::ChangeWriter do
|
|
183
186
|
"last_sign_in_at" => Time.zone.now,
|
184
187
|
},
|
185
188
|
saved_changes: {},
|
189
|
+
journaled_enqueue_opts: {},
|
186
190
|
)
|
187
191
|
end
|
188
192
|
|
@@ -253,6 +257,7 @@ RSpec.describe Journaled::ChangeWriter do
|
|
253
257
|
changes: {
|
254
258
|
"name" => %w(bill bob),
|
255
259
|
},
|
260
|
+
journaled_enqueue_opts: {},
|
256
261
|
)
|
257
262
|
end
|
258
263
|
|
@@ -25,22 +25,7 @@ RSpec.describe Journaled::Event do
|
|
25
25
|
it 'creates a Journaled::Writer with this event and journals it with the default priority' do
|
26
26
|
sample_journaled_event.journal!
|
27
27
|
expect(Journaled::Writer).to have_received(:new)
|
28
|
-
.with(journaled_event: sample_journaled_event
|
29
|
-
expect(mock_journaled_writer).to have_received(:journal!)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'when there is an app job priority is set' do
|
34
|
-
around do |example|
|
35
|
-
orig_priority = Journaled.job_priority
|
36
|
-
Journaled.job_priority = 13
|
37
|
-
example.run
|
38
|
-
Journaled.job_priority = orig_priority
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'creates a Journaled::Writer with this event and journals it with the given priority' do
|
42
|
-
sample_journaled_event.journal!
|
43
|
-
expect(Journaled::Writer).to have_received(:new).with(journaled_event: sample_journaled_event, priority: 13)
|
28
|
+
.with(journaled_event: sample_journaled_event)
|
44
29
|
expect(mock_journaled_writer).to have_received(:journal!)
|
45
30
|
end
|
46
31
|
end
|
@@ -150,4 +135,26 @@ RSpec.describe Journaled::Event do
|
|
150
135
|
end
|
151
136
|
end
|
152
137
|
end
|
138
|
+
|
139
|
+
describe '#journaled_enqueue_opts, .journaled_enqueue_opts' do
|
140
|
+
it 'defaults to an empty hash' do
|
141
|
+
expect(sample_journaled_event.journaled_enqueue_opts).to eq({})
|
142
|
+
expect(sample_journaled_event_class.journaled_enqueue_opts).to eq({})
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'when there are custom opts provided' do
|
146
|
+
let(:sample_journaled_event_class) do
|
147
|
+
Class.new do
|
148
|
+
include Journaled::Event
|
149
|
+
|
150
|
+
journal_attributes :foo, enqueue_with: { priority: 34, foo: 'bar' }
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'merges in the custom opts' do
|
155
|
+
expect(sample_journaled_event.journaled_enqueue_opts).to eq(priority: 34, foo: 'bar')
|
156
|
+
expect(sample_journaled_event_class.journaled_enqueue_opts).to eq(priority: 34, foo: 'bar')
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
153
160
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
RSpec.describe Journaled::Writer do
|
4
|
-
subject { described_class.new journaled_event: journaled_event
|
4
|
+
subject { described_class.new journaled_event: journaled_event }
|
5
5
|
|
6
6
|
describe '#initialize' do
|
7
7
|
context 'when the Journaled Event does not implement all the necessary methods' do
|
@@ -19,6 +19,7 @@ RSpec.describe Journaled::Writer do
|
|
19
19
|
journaled_attributes: {},
|
20
20
|
journaled_partition_key: '',
|
21
21
|
journaled_app_name: nil,
|
22
|
+
journaled_enqueue_opts: {},
|
22
23
|
)
|
23
24
|
end
|
24
25
|
|
@@ -34,6 +35,7 @@ RSpec.describe Journaled::Writer do
|
|
34
35
|
journaled_attributes: { foo: :bar },
|
35
36
|
journaled_partition_key: 'fake_partition_key',
|
36
37
|
journaled_app_name: nil,
|
38
|
+
journaled_enqueue_opts: {},
|
37
39
|
)
|
38
40
|
end
|
39
41
|
|
@@ -67,12 +69,14 @@ RSpec.describe Journaled::Writer do
|
|
67
69
|
allow(File).to receive(:read).with(schema_path).and_return(schema_file_contents)
|
68
70
|
end
|
69
71
|
|
72
|
+
let(:journaled_enqueue_opts) { {} }
|
70
73
|
let(:journaled_event) do
|
71
74
|
double(
|
72
75
|
journaled_schema_name: :fake_schema_name,
|
73
76
|
journaled_attributes: journaled_event_attributes,
|
74
77
|
journaled_partition_key: 'fake_partition_key',
|
75
78
|
journaled_app_name: 'my_app',
|
79
|
+
journaled_enqueue_opts: journaled_enqueue_opts,
|
76
80
|
)
|
77
81
|
end
|
78
82
|
|
@@ -108,18 +112,27 @@ RSpec.describe Journaled::Writer do
|
|
108
112
|
expect(Journaled::Delivery).to have_received(:new).with(hash_including(app_name: 'my_app'))
|
109
113
|
end
|
110
114
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
+
context 'when there is no job priority specified in the enqueue opts' do
|
116
|
+
around do |example|
|
117
|
+
old_priority = Journaled.job_priority
|
118
|
+
Journaled.job_priority = 999
|
119
|
+
example.run
|
120
|
+
Journaled.job_priority = old_priority
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'defaults to the global default' do
|
124
|
+
expect { subject.journal! }.to change {
|
125
|
+
Delayed::Job.where('handler like ?', '%Journaled::Delivery%').where(priority: 999).count
|
126
|
+
}.from(0).to(1)
|
127
|
+
end
|
115
128
|
end
|
116
129
|
|
117
|
-
context 'when
|
118
|
-
|
130
|
+
context 'when there is a job priority specified in the enqueue opts' do
|
131
|
+
let(:journaled_enqueue_opts) { { priority: 13 } }
|
119
132
|
|
120
|
-
it 'enqueues
|
133
|
+
it 'enqueues a Journaled::Delivery object with the given priority' do
|
121
134
|
expect { subject.journal! }.to change {
|
122
|
-
Delayed::Job.where('handler like ?', '%Journaled::Delivery%').where(priority:
|
135
|
+
Delayed::Job.where('handler like ?', '%Journaled::Delivery%').where(priority: 13).count
|
123
136
|
}.from(0).to(1)
|
124
137
|
end
|
125
138
|
end
|
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.
|
4
|
+
version: 2.3.0
|
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-10-29 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: aws-sdk-resources
|
@@ -215,6 +215,20 @@ dependencies:
|
|
215
215
|
- - ">="
|
216
216
|
- !ruby/object:Gem::Version
|
217
217
|
version: '0'
|
218
|
+
- !ruby/object:Gem::Dependency
|
219
|
+
name: sprockets
|
220
|
+
requirement: !ruby/object:Gem::Requirement
|
221
|
+
requirements:
|
222
|
+
- - "<"
|
223
|
+
- !ruby/object:Gem::Version
|
224
|
+
version: '4.0'
|
225
|
+
type: :development
|
226
|
+
prerelease: false
|
227
|
+
version_requirements: !ruby/object:Gem::Requirement
|
228
|
+
requirements:
|
229
|
+
- - "<"
|
230
|
+
- !ruby/object:Gem::Version
|
231
|
+
version: '4.0'
|
218
232
|
- !ruby/object:Gem::Dependency
|
219
233
|
name: timecop
|
220
234
|
requirement: !ruby/object:Gem::Requirement
|
@@ -275,7 +289,7 @@ files:
|
|
275
289
|
- journaled_schemas/journaled/change.json
|
276
290
|
- lib/journaled.rb
|
277
291
|
- lib/journaled/engine.rb
|
278
|
-
- lib/journaled/
|
292
|
+
- lib/journaled/enqueue.rb
|
279
293
|
- lib/journaled/relation_change_protection.rb
|
280
294
|
- lib/journaled/rspec.rb
|
281
295
|
- lib/journaled/version.rb
|
@@ -344,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
344
358
|
- !ruby/object:Gem::Version
|
345
359
|
version: '0'
|
346
360
|
requirements: []
|
347
|
-
rubygems_version: 3.0.
|
361
|
+
rubygems_version: 3.0.6
|
348
362
|
signing_key:
|
349
363
|
specification_version: 4
|
350
364
|
summary: Journaling for Betterment apps.
|
@@ -1,5 +0,0 @@
|
|
1
|
-
module Journaled::JobPriority
|
2
|
-
INTERACTIVE = 0 # These jobs will actively hinder end-user interactions until complete, e.g. assembling a report a user is polling for.
|
3
|
-
USER_VISIBLE = 10 # These jobs have end-user-visible side effects that will not obviously impact customers, e.g. welcome emails
|
4
|
-
EVENTUAL = 20 # These jobs affect business process that are tolerant to some degree of queue backlog, e.g. desk record synchronization
|
5
|
-
end
|