bumbleworks 0.0.74 → 0.0.76
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 +7 -0
- data/.rspec +1 -1
- data/.ruby-version +1 -1
- data/bumbleworks.gemspec +2 -2
- data/lib/bumbleworks.rb +1 -0
- data/lib/bumbleworks/expression.rb +12 -1
- data/lib/bumbleworks/process.rb +10 -0
- data/lib/bumbleworks/process/error_record.rb +14 -0
- data/lib/bumbleworks/schedule.rb +58 -0
- data/lib/bumbleworks/task.rb +2 -1
- data/lib/bumbleworks/task/finder.rb +4 -0
- data/lib/bumbleworks/version.rb +1 -1
- data/lib/bumbleworks/workitem.rb +4 -0
- data/spec/fixtures/schedules.rb +40 -0
- data/spec/integration/entity_spec.rb +7 -7
- data/spec/integration/example_configurations_spec.rb +5 -5
- data/spec/integration/history_storage_spec.rb +9 -9
- data/spec/integration/sample_application_spec.rb +15 -15
- data/spec/lib/bumbleworks/configuration_spec.rb +52 -52
- data/spec/lib/bumbleworks/entity_spec.rb +66 -68
- data/spec/lib/bumbleworks/error_handler_spec.rb +1 -1
- data/spec/lib/bumbleworks/error_logger_spec.rb +5 -5
- data/spec/lib/bumbleworks/expression_spec.rb +34 -12
- data/spec/lib/bumbleworks/hash_storage_spec.rb +2 -2
- data/spec/lib/bumbleworks/participant/base_spec.rb +1 -1
- data/spec/lib/bumbleworks/participant/entity_interactor_spec.rb +20 -20
- data/spec/lib/bumbleworks/participant/error_dispatcher_spec.rb +3 -3
- data/spec/lib/bumbleworks/participant/local_participant_spec.rb +1 -1
- data/spec/lib/bumbleworks/participant_registration_spec.rb +4 -4
- data/spec/lib/bumbleworks/process/error_record_spec.rb +13 -0
- data/spec/lib/bumbleworks/process_definition_spec.rb +30 -24
- data/spec/lib/bumbleworks/process_spec.rb +86 -54
- data/spec/lib/bumbleworks/ruote/exp/broadcast_event_expression_spec.rb +2 -2
- data/spec/lib/bumbleworks/ruote/exp/wait_for_event_expression_spec.rb +4 -4
- data/spec/lib/bumbleworks/ruote_spec.rb +73 -71
- data/spec/lib/bumbleworks/schedule_spec.rb +124 -0
- data/spec/lib/bumbleworks/simple_logger_spec.rb +8 -8
- data/spec/lib/bumbleworks/storage_adapter_spec.rb +16 -16
- data/spec/lib/bumbleworks/support_spec.rb +23 -19
- data/spec/lib/bumbleworks/task/finder_spec.rb +46 -46
- data/spec/lib/bumbleworks/task_spec.rb +188 -167
- data/spec/lib/bumbleworks/tracker_spec.rb +41 -42
- data/spec/lib/bumbleworks/tree_builder_spec.rb +9 -7
- data/spec/lib/bumbleworks/user_spec.rb +35 -35
- data/spec/lib/bumbleworks/workitem_entity_storage_spec.rb +5 -5
- data/spec/lib/bumbleworks/workitem_spec.rb +28 -17
- data/spec/lib/bumbleworks_spec.rb +57 -51
- data/spec/spec_helper.rb +0 -1
- data/spec/support/shared_examples.rb +3 -3
- metadata +35 -54
@@ -1,5 +1,12 @@
|
|
1
1
|
describe Bumbleworks::Task do
|
2
|
-
let(:workflow_item) {
|
2
|
+
let(:workflow_item) {
|
3
|
+
Ruote::Workitem.new({
|
4
|
+
'fields' => {
|
5
|
+
'params' => {'task' => 'go_to_work'},
|
6
|
+
'dispatched_at' => 'some time ago'
|
7
|
+
}
|
8
|
+
})
|
9
|
+
}
|
3
10
|
|
4
11
|
before :each do
|
5
12
|
Bumbleworks::Ruote.register_participants
|
@@ -14,17 +21,18 @@ describe Bumbleworks::Task do
|
|
14
21
|
describe '#not_completable_error_message' do
|
15
22
|
it 'defaults to generic message' do
|
16
23
|
task = described_class.new(workflow_item)
|
17
|
-
task.not_completable_error_message.
|
24
|
+
expect(task.not_completable_error_message).to eq(
|
18
25
|
"This task is not currently completable."
|
26
|
+
)
|
19
27
|
end
|
20
28
|
end
|
21
29
|
|
22
30
|
describe '.autoload_all' do
|
23
31
|
it 'autoloads all task modules in directory' do
|
24
32
|
Bumbleworks.root = File.join(fixtures_path, 'apps', 'with_default_directories')
|
25
|
-
Object.
|
33
|
+
expect(Object).to receive(:autoload).with(:MakeSomeHoneyTask,
|
26
34
|
File.join(Bumbleworks.root, 'tasks', 'make_some_honey_task.rb'))
|
27
|
-
Object.
|
35
|
+
expect(Object).to receive(:autoload).with(:TasteThatMolassesTask,
|
28
36
|
File.join(Bumbleworks.root, 'tasks', 'taste_that_molasses_task.rb'))
|
29
37
|
described_class.autoload_all
|
30
38
|
end
|
@@ -43,9 +51,16 @@ describe Bumbleworks::Task do
|
|
43
51
|
end
|
44
52
|
end
|
45
53
|
|
54
|
+
describe '#dispatched_at' do
|
55
|
+
it 'returns dispatched_at timestamp from workitem' do
|
56
|
+
task = described_class.new(workflow_item)
|
57
|
+
expect(task.dispatched_at).to eq 'some time ago'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
46
61
|
describe '#completable?' do
|
47
62
|
it 'defaults to true on base task' do
|
48
|
-
described_class.new(workflow_item).
|
63
|
+
expect(described_class.new(workflow_item)).to be_completable
|
49
64
|
end
|
50
65
|
end
|
51
66
|
|
@@ -69,7 +84,7 @@ describe Bumbleworks::Task do
|
|
69
84
|
end
|
70
85
|
|
71
86
|
it 'extends new object with task module' do
|
72
|
-
described_class.
|
87
|
+
expect_any_instance_of(described_class).to receive(:extend_module)
|
73
88
|
described_class.new(workflow_item)
|
74
89
|
end
|
75
90
|
end
|
@@ -77,11 +92,11 @@ describe Bumbleworks::Task do
|
|
77
92
|
describe '#reload' do
|
78
93
|
it 'reloads the workitem from the storage participant' do
|
79
94
|
task = described_class.new(workflow_item)
|
80
|
-
task.
|
81
|
-
Bumbleworks.dashboard.storage_participant.
|
95
|
+
allow(task).to receive(:sid).and_return(:the_sid)
|
96
|
+
expect(Bumbleworks.dashboard.storage_participant).to receive(
|
82
97
|
:[]).with(:the_sid).and_return(:amazing_workitem)
|
83
98
|
task.reload
|
84
|
-
task.instance_variable_get(:@workitem).
|
99
|
+
expect(task.instance_variable_get(:@workitem)).to eq(:amazing_workitem)
|
85
100
|
end
|
86
101
|
end
|
87
102
|
|
@@ -91,9 +106,9 @@ describe Bumbleworks::Task do
|
|
91
106
|
observer1, observer2 = double('observer1'), double('observer2')
|
92
107
|
Bumbleworks.observers = [observer1, observer2]
|
93
108
|
task = described_class.new(workflow_item)
|
94
|
-
task.
|
95
|
-
observer1.
|
96
|
-
observer2.
|
109
|
+
expect(task).to receive(:"#{phase}_snoogle").with(:chachunga, :faloop)
|
110
|
+
expect(observer1).to receive(:"#{phase}_snoogle").with(:chachunga, :faloop)
|
111
|
+
expect(observer2).to receive(:"#{phase}_snoogle").with(:chachunga, :faloop)
|
97
112
|
task.send(:"call_#{phase}_hooks", :snoogle, :chachunga, :faloop)
|
98
113
|
end
|
99
114
|
end
|
@@ -109,7 +124,7 @@ describe Bumbleworks::Task do
|
|
109
124
|
end
|
110
125
|
|
111
126
|
it 'is called when task is dispatched' do
|
112
|
-
described_class.
|
127
|
+
expect_any_instance_of(described_class).to receive(:on_dispatch)
|
113
128
|
Bumbleworks.launch!('planting_a_noodle')
|
114
129
|
Bumbleworks.dashboard.wait_for(:horse_feeder)
|
115
130
|
end
|
@@ -119,15 +134,15 @@ describe Bumbleworks::Task do
|
|
119
134
|
Bumbleworks.dashboard.wait_for(:horse_feeder)
|
120
135
|
task = described_class.for_role('horse_feeder').first
|
121
136
|
log_entry = Bumbleworks.logger.entries.last[:entry]
|
122
|
-
log_entry[:action].
|
123
|
-
log_entry[:target_type].
|
124
|
-
log_entry[:target_id].
|
137
|
+
expect(log_entry[:action]).to eq(:dispatch)
|
138
|
+
expect(log_entry[:target_type]).to eq('Task')
|
139
|
+
expect(log_entry[:target_id]).to eq(task.id)
|
125
140
|
end
|
126
141
|
|
127
142
|
it 'calls after hooks' do
|
128
143
|
task = described_class.new(workflow_item)
|
129
|
-
task.
|
130
|
-
task.
|
144
|
+
allow(task).to receive(:log)
|
145
|
+
expect(task).to receive(:call_after_hooks).with(:dispatch)
|
131
146
|
task.on_dispatch
|
132
147
|
end
|
133
148
|
end
|
@@ -135,22 +150,22 @@ describe Bumbleworks::Task do
|
|
135
150
|
describe '#extend_module' do
|
136
151
|
it 'extends with base module and task module' do
|
137
152
|
task = described_class.new(workflow_item)
|
138
|
-
task.
|
139
|
-
task.
|
140
|
-
task.
|
153
|
+
expect(task).to receive(:task_module).and_return(:task_module_double)
|
154
|
+
expect(task).to receive(:extend).with(Bumbleworks::Task::Base).ordered
|
155
|
+
expect(task).to receive(:extend).with(:task_module_double).ordered
|
141
156
|
task.extend_module
|
142
157
|
end
|
143
158
|
|
144
159
|
it 'extends only with base module if no nickname' do
|
145
160
|
task = described_class.new(workflow_item)
|
146
|
-
task.
|
147
|
-
task.
|
161
|
+
allow(task).to receive(:nickname).and_return(nil)
|
162
|
+
expect(task).to receive(:extend).with(Bumbleworks::Task::Base)
|
148
163
|
task.extend_module
|
149
164
|
end
|
150
165
|
|
151
166
|
it 'extends only with base module if task module does not exist' do
|
152
167
|
task = described_class.new(workflow_item)
|
153
|
-
task.
|
168
|
+
expect(task).to receive(:extend).with(Bumbleworks::Task::Base)
|
154
169
|
task.extend_module
|
155
170
|
end
|
156
171
|
end
|
@@ -158,21 +173,21 @@ describe Bumbleworks::Task do
|
|
158
173
|
describe '#task_module' do
|
159
174
|
it 'returns nil if no nickname' do
|
160
175
|
task = described_class.new(workflow_item)
|
161
|
-
task.
|
162
|
-
task.task_module.
|
176
|
+
allow(task).to receive(:nickname).and_return(nil)
|
177
|
+
expect(task.task_module).to be_nil
|
163
178
|
end
|
164
179
|
|
165
180
|
it 'returns constantized task nickname with "Task" appended' do
|
166
181
|
task = described_class.new(workflow_item)
|
167
|
-
Bumbleworks::Support.
|
168
|
-
task.task_module.
|
182
|
+
allow(Bumbleworks::Support).to receive(:constantize).with("GoToWorkTask").and_return(:the_task_module)
|
183
|
+
expect(task.task_module).to eq(:the_task_module)
|
169
184
|
end
|
170
185
|
end
|
171
186
|
|
172
187
|
describe '#id' do
|
173
188
|
it 'returns the sid from the workitem' do
|
174
|
-
workflow_item.
|
175
|
-
described_class.new(workflow_item).id.
|
189
|
+
allow(workflow_item).to receive(:sid).and_return(:an_exciting_id)
|
190
|
+
expect(described_class.new(workflow_item).id).to eq(:an_exciting_id)
|
176
191
|
end
|
177
192
|
end
|
178
193
|
|
@@ -191,10 +206,12 @@ describe Bumbleworks::Task do
|
|
191
206
|
|
192
207
|
# checking for equality by comparing sid, which is the flow expression id
|
193
208
|
# that identifies not only the expression, but its instance
|
194
|
-
described_class.find_by_id(plant_noodle_seed_task.id).sid.
|
209
|
+
expect(described_class.find_by_id(plant_noodle_seed_task.id).sid).to eq(
|
195
210
|
plant_noodle_seed_task.sid
|
196
|
-
|
211
|
+
)
|
212
|
+
expect(described_class.find_by_id(give_the_horse_a_bon_bon_task.id).sid).to eq(
|
197
213
|
give_the_horse_a_bon_bon_task.sid
|
214
|
+
)
|
198
215
|
end
|
199
216
|
|
200
217
|
it 'raises an error if id is nil' do
|
@@ -238,37 +255,37 @@ describe Bumbleworks::Task do
|
|
238
255
|
describe '.order_by_param' do
|
239
256
|
it 'orders returned tasks by given param ascending by default' do
|
240
257
|
tasks = described_class.order_by_param(:priority)
|
241
|
-
tasks.map(&:nickname).
|
258
|
+
expect(tasks.map(&:nickname)).to eq([
|
242
259
|
'appear_authoritative',
|
243
260
|
'panic',
|
244
261
|
'evince_concern',
|
245
262
|
'roll_eyes',
|
246
263
|
'sit_quietly'
|
247
|
-
]
|
264
|
+
])
|
248
265
|
end
|
249
266
|
|
250
267
|
it 'can order in reverse' do
|
251
268
|
tasks = described_class.order_by_param(:priority, :desc)
|
252
|
-
tasks.map(&:nickname).
|
269
|
+
expect(tasks.map(&:nickname)).to eq([
|
253
270
|
'sit_quietly',
|
254
271
|
'roll_eyes',
|
255
272
|
'evince_concern',
|
256
273
|
'panic',
|
257
274
|
'appear_authoritative'
|
258
|
-
]
|
275
|
+
])
|
259
276
|
end
|
260
277
|
end
|
261
278
|
|
262
279
|
describe '.order_by_params' do
|
263
280
|
it 'orders by multiple parameters' do
|
264
281
|
tasks = described_class.order_by_params(:importance => :desc, :priority => :asc)
|
265
|
-
tasks.map(&:nickname).
|
282
|
+
expect(tasks.map(&:nickname)).to eq([
|
266
283
|
'appear_authoritative',
|
267
284
|
'evince_concern',
|
268
285
|
'roll_eyes',
|
269
286
|
'sit_quietly',
|
270
287
|
'panic'
|
271
|
-
]
|
288
|
+
])
|
272
289
|
end
|
273
290
|
end
|
274
291
|
end
|
@@ -290,37 +307,37 @@ describe Bumbleworks::Task do
|
|
290
307
|
describe '.order_by_field' do
|
291
308
|
it 'orders returned tasks by given param ascending by default' do
|
292
309
|
tasks = described_class.for_role('doctor').order_by_field(:strength)
|
293
|
-
tasks.map { |t| [t.nickname, t.wfid] }.
|
310
|
+
expect(tasks.map { |t| [t.nickname, t.wfid] }).to eq([
|
294
311
|
['evince_concern', @wf1.wfid],
|
295
312
|
['evince_concern', @wf2.wfid],
|
296
313
|
['evince_concern', @wf3.wfid],
|
297
314
|
['evince_concern', @wf4.wfid],
|
298
315
|
['evince_concern', @wf5.wfid]
|
299
|
-
]
|
316
|
+
])
|
300
317
|
end
|
301
318
|
|
302
319
|
it 'can order in reverse' do
|
303
320
|
tasks = described_class.for_role('doctor').order_by_field(:strength, :desc)
|
304
|
-
tasks.map { |t| [t.nickname, t.wfid] }.
|
321
|
+
expect(tasks.map { |t| [t.nickname, t.wfid] }).to eq([
|
305
322
|
['evince_concern', @wf5.wfid],
|
306
323
|
['evince_concern', @wf4.wfid],
|
307
324
|
['evince_concern', @wf3.wfid],
|
308
325
|
['evince_concern', @wf2.wfid],
|
309
326
|
['evince_concern', @wf1.wfid]
|
310
|
-
]
|
327
|
+
])
|
311
328
|
end
|
312
329
|
end
|
313
330
|
|
314
331
|
describe '.order_by_fields' do
|
315
332
|
it 'orders by multiple parameters' do
|
316
333
|
tasks = described_class.for_role('doctor').order_by_fields(:group => :asc, :strength => :desc)
|
317
|
-
tasks.map { |t| [t.nickname, t.wfid] }.
|
334
|
+
expect(tasks.map { |t| [t.nickname, t.wfid] }).to eq([
|
318
335
|
['evince_concern', @wf5.wfid],
|
319
336
|
['evince_concern', @wf4.wfid],
|
320
337
|
['evince_concern', @wf2.wfid],
|
321
338
|
['evince_concern', @wf3.wfid],
|
322
339
|
['evince_concern', @wf1.wfid]
|
323
|
-
]
|
340
|
+
])
|
324
341
|
end
|
325
342
|
end
|
326
343
|
end
|
@@ -342,34 +359,34 @@ describe Bumbleworks::Task do
|
|
342
359
|
it 'returns tasks for all given roles' do
|
343
360
|
Bumbleworks.dashboard.wait_for(:father)
|
344
361
|
tasks = described_class.for_roles(['heckler', 'mother'])
|
345
|
-
tasks.map(&:nickname).
|
362
|
+
expect(tasks.map(&:nickname)).to eq([
|
346
363
|
'comment_on_dancing_ability',
|
347
364
|
'ignore_pleas_for_attention'
|
348
|
-
]
|
365
|
+
])
|
349
366
|
end
|
350
367
|
|
351
368
|
it 'works with symbolized role names' do
|
352
369
|
Bumbleworks.dashboard.wait_for(:father)
|
353
370
|
tasks = described_class.for_roles([:heckler, :mother])
|
354
|
-
tasks.map(&:nickname).
|
371
|
+
expect(tasks.map(&:nickname)).to eq([
|
355
372
|
'comment_on_dancing_ability',
|
356
373
|
'ignore_pleas_for_attention'
|
357
|
-
]
|
374
|
+
])
|
358
375
|
end
|
359
376
|
|
360
377
|
it 'returns empty array if no tasks found for given roles' do
|
361
378
|
Bumbleworks.dashboard.wait_for(:father)
|
362
|
-
described_class.for_roles(['elephant']).
|
379
|
+
expect(described_class.for_roles(['elephant'])).to be_empty
|
363
380
|
end
|
364
381
|
|
365
382
|
it 'returns empty array if given empty array' do
|
366
383
|
Bumbleworks.dashboard.wait_for(:father)
|
367
|
-
described_class.for_roles([]).
|
384
|
+
expect(described_class.for_roles([])).to be_empty
|
368
385
|
end
|
369
386
|
|
370
387
|
it 'returns empty array if given nil' do
|
371
388
|
Bumbleworks.dashboard.wait_for(:father)
|
372
|
-
described_class.for_roles(nil).
|
389
|
+
expect(described_class.for_roles(nil)).to be_empty
|
373
390
|
end
|
374
391
|
end
|
375
392
|
|
@@ -398,33 +415,33 @@ describe Bumbleworks::Task do
|
|
398
415
|
rooting_tasks = described_class.for_processes([@rooting_process_1])
|
399
416
|
tasks_for_both = described_class.for_processes([@spunking_process, @rooting_process_1])
|
400
417
|
|
401
|
-
spunking_tasks.map(&:nickname).
|
402
|
-
rooting_tasks.map(&:nickname).
|
403
|
-
tasks_for_both.map(&:nickname).
|
418
|
+
expect(spunking_tasks.map(&:nickname)).to match_array(['spunk', 'complain'])
|
419
|
+
expect(rooting_tasks.map(&:nickname)).to match_array(['get_the_rooting_on', 'scoff'])
|
420
|
+
expect(tasks_for_both.map(&:nickname)).to match_array(['spunk', 'complain', 'get_the_rooting_on', 'scoff'])
|
404
421
|
end
|
405
422
|
|
406
423
|
it 'works with process ids as well' do
|
407
424
|
spunking_tasks = described_class.for_processes([@spunking_process.id])
|
408
|
-
spunking_tasks.map(&:nickname).
|
425
|
+
expect(spunking_tasks.map(&:nickname)).to match_array(['spunk', 'complain'])
|
409
426
|
end
|
410
427
|
|
411
428
|
it 'returns empty array when no tasks for given process id' do
|
412
|
-
described_class.for_processes(['boop']).
|
429
|
+
expect(described_class.for_processes(['boop'])).to be_empty
|
413
430
|
end
|
414
431
|
|
415
432
|
it 'returns empty array if given empty array' do
|
416
|
-
described_class.for_processes([]).
|
433
|
+
expect(described_class.for_processes([])).to be_empty
|
417
434
|
end
|
418
435
|
|
419
436
|
it 'returns empty array if given nil' do
|
420
|
-
described_class.for_processes(nil).
|
437
|
+
expect(described_class.for_processes(nil)).to be_empty
|
421
438
|
end
|
422
439
|
end
|
423
440
|
|
424
441
|
describe '.for_process' do
|
425
442
|
it 'acts as shortcut to .for_processes with one process' do
|
426
|
-
described_class::Finder.
|
427
|
-
described_class.for_process(:one_guy).
|
443
|
+
allow_any_instance_of(described_class::Finder).to receive(:for_processes).with([:one_guy]).and_return(:aha)
|
444
|
+
expect(described_class.for_process(:one_guy)).to eq(:aha)
|
428
445
|
end
|
429
446
|
end
|
430
447
|
|
@@ -441,10 +458,10 @@ describe Bumbleworks::Task do
|
|
441
458
|
Bumbleworks.dashboard.wait_for(:hagrid)
|
442
459
|
|
443
460
|
tasks = described_class.for_role('chalker')
|
444
|
-
tasks.map(&:nickname).
|
461
|
+
expect(tasks.map(&:nickname)).to eq([
|
445
462
|
'make_chalk_drawings',
|
446
463
|
'chalk_it_good_baby'
|
447
|
-
]
|
464
|
+
])
|
448
465
|
end
|
449
466
|
end
|
450
467
|
|
@@ -462,12 +479,12 @@ describe Bumbleworks::Task do
|
|
462
479
|
Bumbleworks.launch!('dog-lifecycle')
|
463
480
|
Bumbleworks.dashboard.wait_for(:cat)
|
464
481
|
@unclaimed = described_class.unclaimed
|
465
|
-
@unclaimed.map(&:nickname).
|
482
|
+
expect(@unclaimed.map(&:nickname)).to match_array(['eat', 'bark', 'pet_dog', 'skip_and_jump'])
|
466
483
|
described_class.all.each do |t|
|
467
484
|
t.claim('radish') unless ['pet_dog', 'bark'].include?(t.nickname)
|
468
485
|
end
|
469
486
|
@unclaimed = described_class.unclaimed
|
470
|
-
@unclaimed.map(&:nickname).
|
487
|
+
expect(@unclaimed.map(&:nickname)).to match_array(['pet_dog', 'bark'])
|
471
488
|
end
|
472
489
|
end
|
473
490
|
|
@@ -484,12 +501,12 @@ describe Bumbleworks::Task do
|
|
484
501
|
end
|
485
502
|
Bumbleworks.launch!('dog-lifecycle')
|
486
503
|
Bumbleworks.dashboard.wait_for(:cat)
|
487
|
-
described_class.claimed.
|
504
|
+
expect(described_class.claimed).to be_empty
|
488
505
|
described_class.all.each_with_index do |t, i|
|
489
506
|
t.claim("radish_#{i}") unless ['pet_dog', 'bark'].include?(t.nickname)
|
490
507
|
end
|
491
508
|
@claimed = described_class.claimed
|
492
|
-
@claimed.map(&:nickname).
|
509
|
+
expect(@claimed.map(&:nickname)).to match_array(['eat', 'skip_and_jump'])
|
493
510
|
end
|
494
511
|
end
|
495
512
|
|
@@ -511,16 +528,14 @@ describe Bumbleworks::Task do
|
|
511
528
|
Bumbleworks.launch!('hand_waggling')
|
512
529
|
Bumbleworks.dashboard.wait_for(:a_lady)
|
513
530
|
tasks = described_class.completable
|
514
|
-
tasks.
|
515
|
-
tasks.map { |t| [t.role, t.nickname] }.should == [
|
531
|
+
expect(tasks.map { |t| [t.role, t.nickname] }).to eq([
|
516
532
|
['a_fella', 'waggle_hands'],
|
517
533
|
['a_lady', 'wiggle_hands']
|
518
|
-
]
|
534
|
+
])
|
519
535
|
tasks = described_class.completable(false)
|
520
|
-
tasks.
|
521
|
-
tasks.map { |t| [t.role, t.nickname] }.should == [
|
536
|
+
expect(tasks.map { |t| [t.role, t.nickname] }).to eq([
|
522
537
|
['a_monkey', 'wuggle_hands']
|
523
|
-
]
|
538
|
+
])
|
524
539
|
end
|
525
540
|
end
|
526
541
|
|
@@ -542,21 +557,21 @@ describe Bumbleworks::Task do
|
|
542
557
|
it 'executes for each found task' do
|
543
558
|
list = []
|
544
559
|
described_class.each { |t| list << t.nickname }
|
545
|
-
list.
|
560
|
+
expect(list).to match_array(['grouch_it_up', 'sing_a_tune', 'steal_booze', 'eat_cabbage'])
|
546
561
|
end
|
547
562
|
end
|
548
563
|
|
549
564
|
describe '.map' do
|
550
565
|
it 'maps result of yielding block with each task' do
|
551
566
|
list = described_class.map { |t| t.nickname }
|
552
|
-
list.
|
567
|
+
expect(list).to match_array(['grouch_it_up', 'sing_a_tune', 'steal_booze', 'eat_cabbage'])
|
553
568
|
end
|
554
569
|
end
|
555
570
|
|
556
571
|
context 'with queries' do
|
557
572
|
it 'checks filters' do
|
558
573
|
list = described_class.for_role('elmo').map { |t| t.nickname }
|
559
|
-
list.
|
574
|
+
expect(list).to match_array(['sing_a_tune', 'steal_booze'])
|
560
575
|
end
|
561
576
|
end
|
562
577
|
end
|
@@ -579,20 +594,19 @@ describe Bumbleworks::Task do
|
|
579
594
|
it 'returns all tasks (with task param) in queue regardless of role' do
|
580
595
|
Bumbleworks.dashboard.wait_for(:dog_legs)
|
581
596
|
tasks = described_class.all
|
582
|
-
tasks.
|
583
|
-
tasks.map { |t| [t.role, t.nickname] }.should == [
|
597
|
+
expect(tasks.map { |t| [t.role, t.nickname] }).to eq([
|
584
598
|
['dog_teeth', 'eat'],
|
585
599
|
['dog_mouth', 'bark'],
|
586
600
|
['everyone', 'pet_dog'],
|
587
601
|
['dog_legs', 'skip_and_jump']
|
588
|
-
]
|
602
|
+
])
|
589
603
|
end
|
590
604
|
|
591
605
|
it 'uses subclass for generation of tasks' do
|
592
606
|
class MyOwnTask < Bumbleworks::Task; end
|
593
607
|
Bumbleworks.dashboard.wait_for(:dog_legs)
|
594
608
|
tasks = MyOwnTask.all
|
595
|
-
tasks.
|
609
|
+
expect(tasks).to be_all { |t| t.class == MyOwnTask }
|
596
610
|
Object.send(:remove_const, :MyOwnTask)
|
597
611
|
end
|
598
612
|
end
|
@@ -601,25 +615,25 @@ describe Bumbleworks::Task do
|
|
601
615
|
subject{described_class.new(workflow_item)}
|
602
616
|
it 'sets values on workitem fields' do
|
603
617
|
subject['hive'] = 'bees at work'
|
604
|
-
workflow_item.fields['hive'].
|
618
|
+
expect(workflow_item.fields['hive']).to eq('bees at work')
|
605
619
|
end
|
606
620
|
|
607
621
|
it 'retuns value from workitem params' do
|
608
622
|
workflow_item.fields['nest'] = 'queen resting'
|
609
|
-
subject['nest'].
|
623
|
+
expect(subject['nest']).to eq('queen resting')
|
610
624
|
end
|
611
625
|
end
|
612
626
|
|
613
627
|
describe '#nickname' do
|
614
628
|
it 'returns the "task" param' do
|
615
|
-
described_class.new(workflow_item).nickname.
|
629
|
+
expect(described_class.new(workflow_item).nickname).to eq('go_to_work')
|
616
630
|
end
|
617
631
|
|
618
632
|
it 'is immutable; cannot be changed by modifying the param' do
|
619
633
|
task = described_class.new(workflow_item)
|
620
|
-
task.nickname.
|
634
|
+
expect(task.nickname).to eq('go_to_work')
|
621
635
|
task.params['task'] = 'what_is_wrong_with_you?'
|
622
|
-
task.nickname.
|
636
|
+
expect(task.nickname).to eq('go_to_work')
|
623
637
|
end
|
624
638
|
end
|
625
639
|
|
@@ -630,7 +644,7 @@ describe Bumbleworks::Task do
|
|
630
644
|
end
|
631
645
|
Bumbleworks.launch!('planting_a_noodle')
|
632
646
|
Bumbleworks.dashboard.wait_for(:noodle_gardener)
|
633
|
-
described_class.all.first.role.
|
647
|
+
expect(described_class.all.first.role).to eq('noodle_gardener')
|
634
648
|
end
|
635
649
|
end
|
636
650
|
|
@@ -648,13 +662,12 @@ describe Bumbleworks::Task do
|
|
648
662
|
end
|
649
663
|
Bumbleworks.launch!('dog-lifecycle')
|
650
664
|
Bumbleworks.dashboard.wait_for(:cat)
|
651
|
-
described_class.for_claimant('radish').
|
665
|
+
expect(described_class.for_claimant('radish')).to be_empty
|
652
666
|
described_class.all.each do |t|
|
653
667
|
t.claim('radish') unless t.nickname == 'pet_dog'
|
654
668
|
end
|
655
669
|
@tasks = described_class.for_claimant('radish')
|
656
|
-
@tasks.
|
657
|
-
@tasks.map(&:nickname).should =~ ['eat', 'bark', 'skip_and_jump']
|
670
|
+
expect(@tasks.map(&:nickname)).to match_array(['eat', 'bark', 'skip_and_jump'])
|
658
671
|
end
|
659
672
|
end
|
660
673
|
|
@@ -680,20 +693,20 @@ describe Bumbleworks::Task do
|
|
680
693
|
end
|
681
694
|
|
682
695
|
it 'returns all tasks with given field' do
|
683
|
-
described_class.with_fields(:grumbles => true).count.
|
684
|
-
described_class.with_fields(:bumby => 'fancy').count.
|
685
|
-
described_class.with_fields(:bumby => 'not_fancy').count.
|
686
|
-
described_class.with_fields(:what => 'ever').
|
696
|
+
expect(described_class.with_fields(:grumbles => true).count).to eq(3)
|
697
|
+
expect(described_class.with_fields(:bumby => 'fancy').count).to eq(1)
|
698
|
+
expect(described_class.with_fields(:bumby => 'not_fancy').count).to eq(2)
|
699
|
+
expect(described_class.with_fields(:what => 'ever')).to be_empty
|
687
700
|
end
|
688
701
|
|
689
702
|
it 'looks up multiple fields at once' do
|
690
|
-
described_class.with_fields(:grumbles => true, :bumby => 'not_fancy').count.
|
691
|
-
described_class.with_fields(:grumbles => false, :bumby => 'not_fancy').
|
703
|
+
expect(described_class.with_fields(:grumbles => true, :bumby => 'not_fancy').count).to eq(2)
|
704
|
+
expect(described_class.with_fields(:grumbles => false, :bumby => 'not_fancy')).to be_empty
|
692
705
|
end
|
693
706
|
|
694
707
|
it 'can be chained' do
|
695
|
-
described_class.with_fields(:grumbles => true).with_fields(:bumby => 'fancy').count.
|
696
|
-
described_class.with_fields(:grumbles => false).with_fields(:bumby => 'not_fancy').
|
708
|
+
expect(described_class.with_fields(:grumbles => true).with_fields(:bumby => 'fancy').count).to eq(1)
|
709
|
+
expect(described_class.with_fields(:grumbles => false).with_fields(:bumby => 'not_fancy')).to be_empty
|
697
710
|
end
|
698
711
|
end
|
699
712
|
|
@@ -709,7 +722,7 @@ describe Bumbleworks::Task do
|
|
709
722
|
Bumbleworks.launch!('existential_pb_and_j', :entity => fake_sandwich)
|
710
723
|
Bumbleworks.dashboard.wait_for(:sandwich)
|
711
724
|
tasks = described_class.for_entity(fake_sandwich)
|
712
|
-
tasks.
|
725
|
+
expect(tasks.size).to eq(2)
|
713
726
|
end
|
714
727
|
end
|
715
728
|
|
@@ -725,8 +738,7 @@ describe Bumbleworks::Task do
|
|
725
738
|
Bumbleworks.launch!('animal_disagreements')
|
726
739
|
Bumbleworks.dashboard.wait_for(:rabbit)
|
727
740
|
tasks = described_class.by_nickname('punch_turtle')
|
728
|
-
tasks.
|
729
|
-
tasks.map(&:role).should =~ ['goose', 'rabbit']
|
741
|
+
expect(tasks.map(&:role)).to match_array(['goose', 'rabbit'])
|
730
742
|
end
|
731
743
|
end
|
732
744
|
|
@@ -743,11 +755,11 @@ describe Bumbleworks::Task do
|
|
743
755
|
|
744
756
|
describe '#claim' do
|
745
757
|
it 'sets token on "claimant" param' do
|
746
|
-
@task.params['claimant'].
|
758
|
+
expect(@task.params['claimant']).to eq('boss')
|
747
759
|
end
|
748
760
|
|
749
761
|
it 'sets claimed_at param' do
|
750
|
-
@task.params['claimed_at'].
|
762
|
+
expect(@task.params['claimed_at']).not_to be_nil
|
751
763
|
end
|
752
764
|
|
753
765
|
it 'raises an error if already claimed by someone else' do
|
@@ -760,67 +772,67 @@ describe Bumbleworks::Task do
|
|
760
772
|
|
761
773
|
it 'calls before_claim and after_claim callbacks' do
|
762
774
|
task = described_class.new(workflow_item)
|
763
|
-
task.
|
764
|
-
task.
|
765
|
-
task.
|
766
|
-
task.
|
775
|
+
allow(task).to receive(:log)
|
776
|
+
expect(task).to receive(:before_claim).with(:doctor_claim).ordered
|
777
|
+
expect(task).to receive(:set_claimant).ordered
|
778
|
+
expect(task).to receive(:after_claim).with(:doctor_claim).ordered
|
767
779
|
task.claim(:doctor_claim)
|
768
780
|
end
|
769
781
|
|
770
782
|
it 'logs event' do
|
771
783
|
log_entry = Bumbleworks.logger.entries.last[:entry]
|
772
|
-
log_entry[:action].
|
773
|
-
log_entry[:actor].
|
784
|
+
expect(log_entry[:action]).to eq(:claim)
|
785
|
+
expect(log_entry[:actor]).to eq('boss')
|
774
786
|
end
|
775
787
|
end
|
776
788
|
|
777
789
|
describe '#claimant' do
|
778
790
|
it 'returns token of who has claim' do
|
779
|
-
@task.claimant.
|
791
|
+
expect(@task.claimant).to eq('boss')
|
780
792
|
end
|
781
793
|
end
|
782
794
|
|
783
795
|
describe '#claimed_at' do
|
784
796
|
it 'returns claimed_at param' do
|
785
|
-
@task.claimed_at.
|
797
|
+
expect(@task.claimed_at).to eq(@task.params['claimed_at'])
|
786
798
|
end
|
787
799
|
end
|
788
800
|
|
789
801
|
describe '#claimed?' do
|
790
802
|
it 'returns true if claimed' do
|
791
|
-
@task.claimed
|
803
|
+
expect(@task.claimed?).to be_truthy
|
792
804
|
end
|
793
805
|
|
794
806
|
it 'false otherwise' do
|
795
807
|
@task.params['claimant'] = nil
|
796
|
-
@task.claimed
|
808
|
+
expect(@task.claimed?).to be_falsy
|
797
809
|
end
|
798
810
|
end
|
799
811
|
|
800
812
|
describe '#release' do
|
801
813
|
it "release claim on workitem" do
|
802
|
-
@task.
|
814
|
+
expect(@task).to be_claimed
|
803
815
|
@task.release
|
804
|
-
@task.
|
816
|
+
expect(@task).not_to be_claimed
|
805
817
|
end
|
806
818
|
|
807
819
|
it 'clears claimed_at param' do
|
808
820
|
@task.release
|
809
|
-
@task.params['claimed_at'].
|
821
|
+
expect(@task.params['claimed_at']).to be_nil
|
810
822
|
end
|
811
823
|
|
812
824
|
it 'calls with hooks' do
|
813
|
-
@task.
|
814
|
-
@task.
|
815
|
-
@task.
|
825
|
+
expect(@task).to receive(:call_before_hooks).with(:release, 'boss').ordered
|
826
|
+
expect(@task).to receive(:set_claimant).ordered
|
827
|
+
expect(@task).to receive(:call_after_hooks).with(:release, 'boss').ordered
|
816
828
|
@task.release
|
817
829
|
end
|
818
830
|
|
819
831
|
it 'logs event' do
|
820
832
|
@task.release
|
821
833
|
log_entry = Bumbleworks.logger.entries.last[:entry]
|
822
|
-
log_entry[:action].
|
823
|
-
log_entry[:actor].
|
834
|
+
expect(log_entry[:action]).to eq(:release)
|
835
|
+
expect(log_entry[:actor]).to eq('boss')
|
824
836
|
end
|
825
837
|
end
|
826
838
|
end
|
@@ -842,27 +854,36 @@ describe Bumbleworks::Task do
|
|
842
854
|
task.fields['meal'] = 'salted_rhubarb'
|
843
855
|
task.update
|
844
856
|
task = described_class.for_role('dog_mouth').first
|
845
|
-
task.params['state'].
|
846
|
-
task.fields['meal'].
|
857
|
+
expect(task.params['state']).to eq('is ready')
|
858
|
+
expect(task.fields['meal']).to eq('salted_rhubarb')
|
847
859
|
end
|
848
860
|
|
849
861
|
it 'calls with hooks' do
|
850
862
|
task = described_class.new(workflow_item)
|
851
|
-
task.
|
852
|
-
task.
|
853
|
-
task.
|
854
|
-
task.
|
863
|
+
allow(task).to receive(:log)
|
864
|
+
expect(task).to receive(:call_before_hooks).with(:update, :argue_mints).ordered
|
865
|
+
expect(task).to receive(:update_workitem).ordered
|
866
|
+
expect(task).to receive(:call_after_hooks).with(:update, :argue_mints).ordered
|
855
867
|
task.update(:argue_mints)
|
856
868
|
end
|
857
869
|
|
870
|
+
it 'reloads after updating workitem' do
|
871
|
+
event = Bumbleworks.dashboard.wait_for :dog_mouth
|
872
|
+
task = described_class.for_role('dog_mouth').first
|
873
|
+
allow(task).to receive(:log)
|
874
|
+
expect(described_class.storage_participant).to receive(:update).with(task.workitem).ordered
|
875
|
+
expect(task).to receive(:reload).ordered
|
876
|
+
task.update(:noofles)
|
877
|
+
end
|
878
|
+
|
858
879
|
it 'logs event' do
|
859
880
|
event = Bumbleworks.dashboard.wait_for :dog_mouth
|
860
881
|
task = described_class.for_role('dog_mouth').first
|
861
882
|
task.params['claimant'] = :some_user
|
862
883
|
task.update(:extra_data => :fancy)
|
863
|
-
Bumbleworks.logger.entries.last.
|
884
|
+
expect(Bumbleworks.logger.entries.last).to eq({
|
864
885
|
:level => :info, :entry => {
|
865
|
-
:actor =>
|
886
|
+
:actor => "some_user", # claimant is a string after #reload
|
866
887
|
:action => :update,
|
867
888
|
:target_type => 'Task',
|
868
889
|
:target_id => task.id,
|
@@ -871,7 +892,7 @@ describe Bumbleworks::Task do
|
|
871
892
|
:current_fields => task.fields
|
872
893
|
}
|
873
894
|
}
|
874
|
-
}
|
895
|
+
})
|
875
896
|
end
|
876
897
|
end
|
877
898
|
|
@@ -882,37 +903,37 @@ describe Bumbleworks::Task do
|
|
882
903
|
task.params['state'] = 'is ready'
|
883
904
|
task.fields['meal'] = 'root beer and a kite'
|
884
905
|
task.complete
|
885
|
-
described_class.for_role('dog_mouth').
|
906
|
+
expect(described_class.for_role('dog_mouth')).to be_empty
|
886
907
|
event = Bumbleworks.dashboard.wait_for :dog_brain
|
887
908
|
task = described_class.for_role('dog_brain').first
|
888
|
-
task.params['state'].
|
889
|
-
task.fields['meal'].
|
909
|
+
expect(task.params['state']).to be_nil
|
910
|
+
expect(task.fields['meal']).to eq('root beer and a kite')
|
890
911
|
end
|
891
912
|
|
892
913
|
it 'throws exception if task is not completable' do
|
893
914
|
event = Bumbleworks.dashboard.wait_for :dog_mouth
|
894
915
|
task = described_class.for_role('dog_mouth').first
|
895
|
-
task.
|
896
|
-
task.
|
897
|
-
task.
|
898
|
-
task.
|
899
|
-
task.
|
900
|
-
task.
|
901
|
-
task.
|
916
|
+
allow(task).to receive(:completable?).and_return(false)
|
917
|
+
allow(task).to receive(:not_completable_error_message).and_return('hogwash!')
|
918
|
+
expect(task).to receive(:before_update).never
|
919
|
+
expect(task).to receive(:before_complete).never
|
920
|
+
expect(task).to receive(:proceed_workitem).never
|
921
|
+
expect(task).to receive(:after_complete).never
|
922
|
+
expect(task).to receive(:after_update).never
|
902
923
|
expect {
|
903
924
|
task.complete
|
904
925
|
}.to raise_error(Bumbleworks::Task::NotCompletable, "hogwash!")
|
905
|
-
described_class.for_role('dog_mouth').
|
926
|
+
expect(described_class.for_role('dog_mouth')).not_to be_empty
|
906
927
|
end
|
907
928
|
|
908
929
|
it 'calls update and complete callbacks' do
|
909
930
|
task = described_class.new(workflow_item)
|
910
|
-
task.
|
911
|
-
task.
|
912
|
-
task.
|
913
|
-
task.
|
914
|
-
task.
|
915
|
-
task.
|
931
|
+
allow(task).to receive(:log)
|
932
|
+
expect(task).to receive(:call_before_hooks).with(:update, :argue_mints).ordered
|
933
|
+
expect(task).to receive(:call_before_hooks).with(:complete, :argue_mints).ordered
|
934
|
+
expect(task).to receive(:proceed_workitem).ordered
|
935
|
+
expect(task).to receive(:call_after_hooks).with(:complete, :argue_mints).ordered
|
936
|
+
expect(task).to receive(:call_after_hooks).with(:update, :argue_mints).ordered
|
916
937
|
task.complete(:argue_mints)
|
917
938
|
end
|
918
939
|
|
@@ -921,7 +942,7 @@ describe Bumbleworks::Task do
|
|
921
942
|
task = described_class.for_role('dog_mouth').first
|
922
943
|
task.params['claimant'] = :some_user
|
923
944
|
task.complete(:extra_data => :fancy)
|
924
|
-
Bumbleworks.logger.entries.last.
|
945
|
+
expect(Bumbleworks.logger.entries.last).to eq({
|
925
946
|
:level => :info, :entry => {
|
926
947
|
:actor => :some_user,
|
927
948
|
:action => :complete,
|
@@ -932,7 +953,7 @@ describe Bumbleworks::Task do
|
|
932
953
|
:current_fields => task.fields
|
933
954
|
}
|
934
955
|
}
|
935
|
-
}
|
956
|
+
})
|
936
957
|
end
|
937
958
|
end
|
938
959
|
end
|
@@ -966,37 +987,37 @@ describe Bumbleworks::Task do
|
|
966
987
|
tasks = described_class.
|
967
988
|
for_roles(['green', 'pink']).
|
968
989
|
by_nickname('be_proud')
|
969
|
-
tasks.map(&:nickname).
|
990
|
+
expect(tasks.map(&:nickname)).to match_array(['be_proud', 'be_proud'])
|
970
991
|
|
971
992
|
tasks = described_class.
|
972
993
|
for_roles(['green', 'pink', 'blue']).
|
973
994
|
completable.
|
974
995
|
by_nickname('be_proud')
|
975
|
-
tasks.map(&:nickname).
|
976
|
-
tasks.first.role.
|
996
|
+
expect(tasks.map(&:nickname)).to match_array(['be_proud'])
|
997
|
+
expect(tasks.first.role).to eq('pink')
|
977
998
|
|
978
999
|
tasks = described_class.
|
979
1000
|
for_claimant('crayon_box').
|
980
1001
|
for_roles(['red', 'yellow', 'green'])
|
981
|
-
tasks.map(&:nickname).
|
1002
|
+
expect(tasks.map(&:nickname)).to match_array(['be_really_mad', 'be_scared'])
|
982
1003
|
|
983
1004
|
tasks = described_class.
|
984
1005
|
for_claimant('crayon_box').
|
985
1006
|
by_nickname('be_a_bit_sad').
|
986
1007
|
for_role('blue')
|
987
|
-
tasks.map(&:nickname).
|
1008
|
+
expect(tasks.map(&:nickname)).to eq(['be_a_bit_sad'])
|
988
1009
|
end
|
989
1010
|
|
990
1011
|
it 'allows for OR-ed chained finders' do
|
991
1012
|
tasks = described_class.where_any.
|
992
1013
|
for_role('blue').
|
993
1014
|
by_nickname('be_proud')
|
994
|
-
tasks.map(&:nickname).
|
1015
|
+
expect(tasks.map(&:nickname)).to match_array(['be_a_bit_sad', 'be_proud', 'be_proud'])
|
995
1016
|
|
996
1017
|
tasks = described_class.where_any.
|
997
1018
|
completable.
|
998
1019
|
claimed
|
999
|
-
tasks.map(&:nickname).
|
1020
|
+
expect(tasks.map(&:nickname)).to match_array(['be_really_mad', 'be_scared', 'be_a_bit_sad', 'be_envious', 'be_proud'])
|
1000
1021
|
end
|
1001
1022
|
|
1002
1023
|
it 'allows for combination of AND-ed and OR-ed finders' do
|
@@ -1004,14 +1025,14 @@ describe Bumbleworks::Task do
|
|
1004
1025
|
for_claimant('crayon_box').
|
1005
1026
|
for_roles(['red', 'yellow', 'green']).
|
1006
1027
|
where_any(:nickname => 'spittle', :role => 'red')
|
1007
|
-
tasks.map(&:nickname).
|
1028
|
+
expect(tasks.map(&:nickname)).to match_array(['be_really_mad'])
|
1008
1029
|
end
|
1009
1030
|
end
|
1010
1031
|
|
1011
1032
|
describe 'method missing' do
|
1012
1033
|
it 'calls method on new Finder object' do
|
1013
|
-
described_class::Finder.
|
1014
|
-
described_class.shabam!(:yay).
|
1034
|
+
allow_any_instance_of(described_class::Finder).to receive(:shabam!).with(:yay).and_return(:its_a_me)
|
1035
|
+
expect(described_class.shabam!(:yay)).to eq(:its_a_me)
|
1015
1036
|
end
|
1016
1037
|
|
1017
1038
|
it 'falls back to method missing if no finder method' do
|
@@ -1036,8 +1057,8 @@ describe Bumbleworks::Task do
|
|
1036
1057
|
Bumbleworks.launch!('lazy_bum_and_cool_guy')
|
1037
1058
|
task = described_class.for_role('bum').next_available
|
1038
1059
|
end_time = Time.now
|
1039
|
-
task.nickname.
|
1040
|
-
(end_time - start_time).
|
1060
|
+
expect(task.nickname).to eq('finally_get_a_round_tuit')
|
1061
|
+
expect(end_time - start_time).to be >= 2
|
1041
1062
|
end
|
1042
1063
|
|
1043
1064
|
it 'times out if task does not appear in time' do
|
@@ -1060,50 +1081,50 @@ describe Bumbleworks::Task do
|
|
1060
1081
|
describe '#humanize' do
|
1061
1082
|
it "returns humanized version of task name when no entity" do
|
1062
1083
|
task = described_class.new(workflow_item)
|
1063
|
-
task.humanize.
|
1084
|
+
expect(task.humanize).to eq('Go to work')
|
1064
1085
|
end
|
1065
1086
|
|
1066
1087
|
it "returns humanized version of task name with entity" do
|
1067
1088
|
task = described_class.new(workflow_item)
|
1068
1089
|
task[:entity_id] = '45'
|
1069
1090
|
task[:entity_type] = 'RhubarbSandwich'
|
1070
|
-
task.humanize.
|
1091
|
+
expect(task.humanize).to eq('Go to work: Rhubarb sandwich 45')
|
1071
1092
|
end
|
1072
1093
|
|
1073
1094
|
it "returns humanized version of task name without entity if requested" do
|
1074
1095
|
task = described_class.new(workflow_item)
|
1075
1096
|
task[:entity_id] = '45'
|
1076
1097
|
task[:entity_type] = 'RhubarbSandwich'
|
1077
|
-
task.humanize(:entity => false).
|
1098
|
+
expect(task.humanize(:entity => false)).to eq('Go to work')
|
1078
1099
|
end
|
1079
1100
|
end
|
1080
1101
|
|
1081
1102
|
describe '#to_s' do
|
1082
1103
|
it "is aliased to #titleize" do
|
1083
1104
|
task = described_class.new(workflow_item)
|
1084
|
-
task.
|
1085
|
-
task.to_s(:the_args).
|
1105
|
+
allow(task).to receive(:titleize).with(:the_args).and_return(:see_i_told_you_so)
|
1106
|
+
expect(task.to_s(:the_args)).to eq(:see_i_told_you_so)
|
1086
1107
|
end
|
1087
1108
|
end
|
1088
1109
|
|
1089
1110
|
describe '#titleize' do
|
1090
1111
|
it "returns titleized version of task name when no entity" do
|
1091
1112
|
task = described_class.new(workflow_item)
|
1092
|
-
task.titleize.
|
1113
|
+
expect(task.titleize).to eq('Go To Work')
|
1093
1114
|
end
|
1094
1115
|
|
1095
1116
|
it "returns titleized version of task name with entity" do
|
1096
1117
|
task = described_class.new(workflow_item)
|
1097
1118
|
task[:entity_id] = '45'
|
1098
1119
|
task[:entity_type] = 'RhubarbSandwich'
|
1099
|
-
task.titleize.
|
1120
|
+
expect(task.titleize).to eq('Go To Work: Rhubarb Sandwich 45')
|
1100
1121
|
end
|
1101
1122
|
|
1102
1123
|
it "returns titleized version of task name without entity if requested" do
|
1103
1124
|
task = described_class.new(workflow_item)
|
1104
1125
|
task[:entity_id] = '45'
|
1105
1126
|
task[:entity_type] = 'RhubarbSandwich'
|
1106
|
-
task.titleize(:entity => false).
|
1127
|
+
expect(task.titleize(:entity => false)).to eq('Go To Work')
|
1107
1128
|
end
|
1108
1129
|
end
|
1109
1130
|
end
|