spec/models/entity_spec.rb in maestrano-connector-rails-0.4.0 vs spec/models/entity_spec.rb in maestrano-connector-rails-0.4.1

- old
+ new

@@ -277,11 +277,11 @@ end end describe 'without response' do before { - allow(client).to receive(:get).and_return(nil) + allow(client).to receive(:get).and_return(ActionDispatch::Response.new(200, {}, nil, {})) } it { expect{ subject.get_connec_entities(client, nil, organization) }.to raise_error("No data received from Connec! when trying to fetch #{connec_name.pluralize.downcase}") } end end @@ -316,11 +316,11 @@ end context 'when create_only' do before { allow(subject.class).to receive(:can_update_connec?).and_return(false) - allow(client).to receive(:post).and_return(ActionDispatch::Response.new(200, {}, {results: []}.to_json, {})) + allow(client).to receive(:batch).and_return(ActionDispatch::Response.new(200, {}, {results: []}.to_json, {})) } it 'creates batch op for create only' do expect(subject).to receive(:batch_op).once.with('post', entity2, nil, connec_name.downcase.pluralize, organization) expect(subject).to_not receive(:batch_op).with('put', any_args) @@ -330,11 +330,11 @@ context 'without errors' do let(:result200) { {status: 200, body: {connec_name.downcase.pluralize.to_sym => {}}} } let(:result201) { {status: 201, body: {connec_name.downcase.pluralize.to_sym => {id: id}}} } before { - allow(client).to receive(:post).and_return(ActionDispatch::Response.new(200, {}, {results: [result200, result201]}.to_json, {})) + allow(client).to receive(:batch).and_return(ActionDispatch::Response.new(200, {}, {results: [result200, result201]}.to_json, {})) } let(:batch_request) { { sequential: true, @@ -357,11 +357,11 @@ expect(subject).to receive(:batch_op).twice subject.push_entities_to_connec_to(client, entities_with_idmaps, connec_name, organization) end it 'creates a batch request' do - expect(client).to receive(:post).with('/batch', batch_request) + expect(client).to receive(:batch).with(batch_request) subject.push_entities_to_connec_to(client, entities_with_idmaps, connec_name, organization) end it 'update the idmaps' do old_push_date = idmap1.last_push_to_connec @@ -383,15 +383,15 @@ before { 100.times do entities << entity_with_idmap1 results << result200 end - allow(client).to receive(:post).and_return(ActionDispatch::Response.new(200, {}, {results: results}.to_json, {})) + allow(client).to receive(:batch).and_return(ActionDispatch::Response.new(200, {}, {results: results}.to_json, {})) } it 'does one call' do - expect(client).to receive(:post).once + expect(client).to receive(:batch).once subject.push_entities_to_connec_to(client, entities, connec_name, organization) end end context 'when more than 100 entities' do @@ -399,15 +399,15 @@ 100.times do entities << entity_with_idmap1 results << result200 end entities << entity_with_idmap2 - allow(client).to receive(:post).and_return(ActionDispatch::Response.new(200, {}, {results: results}.to_json, {}), ActionDispatch::Response.new(200, {}, {results: [result201]}.to_json, {})) + allow(client).to receive(:batch).and_return(ActionDispatch::Response.new(200, {}, {results: results}.to_json, {}), ActionDispatch::Response.new(200, {}, {results: [result201]}.to_json, {})) } it 'does several call' do - expect(client).to receive(:post).twice + expect(client).to receive(:batch).twice subject.push_entities_to_connec_to(client, entities, connec_name, organization) end it 'updates the idmap' do subject.push_entities_to_connec_to(client, entities, connec_name, organization) @@ -420,10 +420,10 @@ end context 'with errors' do let(:result400) { {status: 400, body: 'Not Found'} } before { - allow(client).to receive(:post).and_return(ActionDispatch::Response.new(200, {}, {results: [result400, result400]}.to_json, {})) + allow(client).to receive(:batch).and_return(ActionDispatch::Response.new(200, {}, {results: [result400, result400]}.to_json, {})) } it 'stores the errr in the idmap' do subject.push_entities_to_connec_to(client, entities_with_idmaps, '', organization) idmap2.reload \ No newline at end of file