|
7 | 7 | let(:strategy) { instance_double('Userlist::Push::Strategies::Direct') } |
8 | 8 | let(:resource) { resource_type.from_payload(payload) } |
9 | 9 |
|
| 10 | + let(:identifier) { 'identifier' } |
10 | 11 | let(:payload) do |
11 | 12 | { |
12 | | - identifier: 'identifier', |
| 13 | + identifier: identifier, |
13 | 14 | properties: { |
14 | 15 | first_name: 'John', |
15 | 16 | last_name: 'Doe' |
|
38 | 39 | end |
39 | 40 |
|
40 | 41 | it 'should set the context to :push' do |
41 | | - expect(strategy).to receive(:call).with(:post, '/users', satisfy { |r| r.context == :push }) |
| 42 | + expect(strategy).to receive(:call).with(:post, '/users', satisfy { |r| r.options[:context] == :push }) |
42 | 43 | relation.push(payload) |
43 | 44 | end |
44 | 45 | end |
|
52 | 53 | end |
53 | 54 |
|
54 | 55 | it 'should set the context to :push' do |
55 | | - expect(strategy).to receive(:call).with(:post, '/users', satisfy { |r| r.context == :push }) |
| 56 | + expect(strategy).to receive(:call).with(:post, '/users', satisfy { |r| r.options[:context] == :push }) |
56 | 57 | relation.push(payload) |
57 | 58 | end |
58 | 59 | end |
59 | 60 |
|
60 | 61 | context 'when given an identifier' do |
61 | 62 | let(:payload) do |
62 | | - { identifier: 'identifier' } |
| 63 | + { identifier: identifier } |
63 | 64 | end |
64 | 65 |
|
65 | 66 | it 'should send a simple payload to the endpoint' do |
|
77 | 78 | end |
78 | 79 | end |
79 | 80 |
|
| 81 | + context 'when given keyword arguments as payload' do |
| 82 | + let(:payload) do |
| 83 | + { identifier: identifier } |
| 84 | + end |
| 85 | + |
| 86 | + it 'should send the request to the endpoint' do |
| 87 | + expect(strategy).to receive(:call).with(:post, '/users', resource.with(context: :push)) |
| 88 | + relation.push(identifier:) |
| 89 | + end |
| 90 | + end |
| 91 | + |
80 | 92 | context 'when the operation is not permitted' do |
81 | 93 | before do |
82 | 94 | allow_any_instance_of(resource_type).to receive(:push?).and_return(false) |
|
0 commit comments