Skip to content

Commit 587eeb2

Browse files
WilliamBZAMichał Wójcik
authored andcommitted
Don't throw on missing header (#722)
* Don't throw on missing header * Adding nasty tests to verify the change
1 parent c0f1569 commit 587eeb2

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/ServicePulse.Host.Tests/tests/js/views/message/controller.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,23 @@
6969
expect(controller.message.retried).toEqual(false);
7070
expect(serviceControlService.retryFailedMessages).toHaveBeenCalled();
7171
});
72+
73+
it('and the headers contain content type, GetContentType returns it', function () {
74+
var originalValue = 'xml';
75+
var headers = [];
76+
headers.push({key: 'NServiceBus.ContentType', value: originalValue});
77+
headers.push({key: 'bla', value:1});
78+
var headerValue = controller.getContentType(headers);
79+
80+
expect(headerValue).toEqual(originalValue);
81+
});
82+
83+
it('and the headers are empty GetContentType returns null', function () {
84+
var headers = [];
85+
var headerValue = controller.getContentType(headers);
86+
87+
expect(headerValue).toEqual(null);
88+
});
7289
});
7390

7491
describe('when archiving a message', function () {

src/ServicePulse.Host/app/js/views/message/controller.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@
8686
}
8787

8888
function getContentType(headers) {
89-
return headers.find(function (element) { return element.key === 'NServiceBus.ContentType'; }).value;
89+
var header = headers.find(function (element) { return element.key === 'NServiceBus.ContentType'; });
90+
return header ? header.value : null;
9091
}
92+
93+
vm.getContentType = getContentType;
9194

9295
vm.retryMessage = function () {
9396
toastService.showInfo("Retrying the message " + vm.message.message_id + " ...");

0 commit comments

Comments
 (0)