|
11 | 11 |
|
12 | 12 | TestWorker.perform_async('test')
|
13 | 13 | end
|
| 14 | + |
| 15 | + it 'properly sets message_attributes' do |
| 16 | + custom_attributes = { |
| 17 | + 'custom_key' => { string_value: 'custom_value', data_type: 'String' } |
| 18 | + } |
| 19 | + |
| 20 | + expect_any_instance_of(TestWorker).to receive(:perform) do |_, sqs_msg, _| |
| 21 | + expect(sqs_msg.message_attributes).to include('shoryuken_class') |
| 22 | + expect(sqs_msg.message_attributes).to include('custom_key') |
| 23 | + expect(sqs_msg.message_attributes['custom_key'][:string_value]).to eq('custom_value') |
| 24 | + end |
| 25 | + |
| 26 | + TestWorker.perform_async('test', message_attributes: custom_attributes) |
| 27 | + end |
14 | 28 | end
|
15 | 29 |
|
16 | 30 | describe '.perform_in' do
|
|
19 | 33 |
|
20 | 34 | TestWorker.perform_in(60, 'test')
|
21 | 35 | end
|
| 36 | + |
| 37 | + it 'properly passes message_attributes to perform_async' do |
| 38 | + custom_attributes = { |
| 39 | + 'custom_key' => { string_value: 'custom_value', data_type: 'String' } |
| 40 | + } |
| 41 | + |
| 42 | + expect_any_instance_of(TestWorker).to receive(:perform) do |_, sqs_msg, _| |
| 43 | + expect(sqs_msg.message_attributes).to include('shoryuken_class') |
| 44 | + expect(sqs_msg.message_attributes).to include('custom_key') |
| 45 | + expect(sqs_msg.message_attributes['custom_key'][:string_value]).to eq('custom_value') |
| 46 | + end |
| 47 | + |
| 48 | + TestWorker.perform_in(60, 'test', message_attributes: custom_attributes) |
| 49 | + end |
22 | 50 | end
|
23 | 51 |
|
24 | 52 | context 'batch' do
|
|
36 | 64 |
|
37 | 65 | TestWorker.perform_async('test')
|
38 | 66 | end
|
| 67 | + |
| 68 | + it 'properly passes message_attributes with batch' do |
| 69 | + custom_attributes = { |
| 70 | + 'custom_key' => { string_value: 'custom_value', data_type: 'String' } |
| 71 | + } |
| 72 | + |
| 73 | + expect_any_instance_of(TestWorker).to receive(:perform) do |_, sqs_msgs, _| |
| 74 | + expect(sqs_msgs.first.message_attributes).to include('shoryuken_class') |
| 75 | + expect(sqs_msgs.first.message_attributes).to include('custom_key') |
| 76 | + expect(sqs_msgs.first.message_attributes['custom_key'][:string_value]).to eq('custom_value') |
| 77 | + end |
| 78 | + |
| 79 | + TestWorker.perform_async('test', message_attributes: custom_attributes) |
| 80 | + end |
39 | 81 | end
|
40 | 82 |
|
41 | 83 | describe '.perform_in' do
|
|
44 | 86 |
|
45 | 87 | TestWorker.perform_in(60, 'test')
|
46 | 88 | end
|
| 89 | + |
| 90 | + it 'properly passes message_attributes with batch' do |
| 91 | + custom_attributes = { |
| 92 | + 'custom_key' => { string_value: 'custom_value', data_type: 'String' } |
| 93 | + } |
| 94 | + |
| 95 | + expect_any_instance_of(TestWorker).to receive(:perform) do |_, sqs_msgs, _| |
| 96 | + expect(sqs_msgs.first.message_attributes).to include('shoryuken_class') |
| 97 | + expect(sqs_msgs.first.message_attributes).to include('custom_key') |
| 98 | + expect(sqs_msgs.first.message_attributes['custom_key'][:string_value]).to eq('custom_value') |
| 99 | + end |
| 100 | + |
| 101 | + TestWorker.perform_in(60, 'test', message_attributes: custom_attributes) |
| 102 | + end |
47 | 103 | end
|
48 | 104 | end
|
49 | 105 | end
|
0 commit comments