Skip to content

Commit

Permalink
fix(sender-link): raw message payloads should merge link options
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed May 31, 2016
1 parent 6270331 commit 8e48a3f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/sender_link.js
Expand Up @@ -75,6 +75,7 @@ SenderLink.prototype.send = function(msg, options) {
if (u.isObject(msg) && msg.hasOwnProperty('body')) {
message = msg;
message.body = self.policy.encoder ? self.policy.encoder(message.body) : message.body;
u.merge(message, options);
} else {
msg = self.policy.encoder ? self.policy.encoder(msg) : msg;
if (u.isObject(options)) {
Expand Down
16 changes: 8 additions & 8 deletions package.json
Expand Up @@ -9,23 +9,23 @@
"dependencies": {
"buffer-builder": "^0.2.0",
"bl": "^1.1.2",
"bluebird": "^3.3.1",
"bluebird": "^3.4.0",
"debug": "^2.2.0",
"lodash": "^4.5.0",
"lodash": "^4.13.1",
"node-amqp-encoder": "^0.0.2",
"node-int64": "^0.4.0",
"stately.js": "^1.3.0",
"uuid": "^2.0.1"
"uuid": "^2.0.2"
},
"devDependencies": {
"benchmark": "^2.1.0",
"chai": "^3.5.0",
"chai-string": "^1.2.0",
"conventional-changelog-cli": "^1.1.1",
"istanbul": "^0.4.2",
"jsdoc-to-markdown": "^1.3.3",
"jshint": "^2.9.1",
"mocha": "^2.4.5",
"conventional-changelog-cli": "^1.2.0",
"istanbul": "^0.4.3",
"jsdoc-to-markdown": "^1.3.6",
"jshint": "^2.9.2",
"mocha": "^2.5.3",
"qmf2": "^0.1.5",
"stream-buffers": "^3.0.0"
},
Expand Down
22 changes: 22 additions & 0 deletions test/integration/qpid/sender_link.test.js
Expand Up @@ -41,6 +41,28 @@ describe('SenderLink', function() {
});
});

it('should merge default subject if sent message is raw', function(done) {
return test.client.connect(config.address)
.then(function() {
return Promise.all([
test.client.createReceiver('amq.topic/not-news'),
test.client.createReceiver('amq.topic/news'),
test.client.createSender('amq.topic/news')
]);
})
.spread(function(receiverWithoutSubject, receiverWithSubject, sender) {
receiverWithoutSubject.on('message', function(message) {
expect(message).to.not.exist;
});

receiverWithSubject.on('message', function(message) {
done();
});

return sender.send({ body: 'test message' });
});
});

it('should accept messages as the first parameter', function(done) {
return test.client.connect(config.address)
.then(function() {
Expand Down

0 comments on commit 8e48a3f

Please sign in to comment.