spec/models/entity_spec.rb in maestrano-connector-rails-0.4.3 vs spec/models/entity_spec.rb in maestrano-connector-rails-0.4.4
- old
+ new
@@ -418,20 +418,30 @@
end
end
end
context 'with errors' do
- let(:result400) { {status: 400, body: 'Not Found'} }
+ let(:err_msg) { 'Not Found' }
+ let(:result400) { {status: 400, body: err_msg} }
before {
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
expect(idmap2.message).to eq result400[:body]
end
+
+ context 'with a long error message' do
+ let(:err_msg) { 'A very long sentence with a lot of error or more likely a badly designed API that return an html 404 page instead of a nice json answer an then the world is sad and the kitten are unhappy. So juste to be safe we are truncating the error message and I am running out of words to write I hope it is long enough' }
+ it 'truncates the error message' do
+ subject.push_entities_to_connec_to(client, entities_with_idmaps, '', organization)
+ idmap2.reload
+ expect(idmap2.message).to eq err_msg.truncate(255)
+ end
+ end
end
end
describe 'map_to_external_with_idmap' do
let(:organization) { create(:organization) }
@@ -502,9 +512,13 @@
it 'save the entity name in the idmap' do
subject.map_to_external_with_idmap(entity, organization)
expect(Maestrano::Connector::Rails::IdMap.last.name).to eql('human readable stuff')
end
end
+ end
+
+ describe 'filter_connec_entities' do
+ it { expect(subject.filter_connec_entities([{a: 2}], organization)).to eql([{a: 2}]) }
end
end
# External methods
\ No newline at end of file