Skip to content

Commit

Permalink
Merge pull request #330 from pilwon/patch-1
Browse files Browse the repository at this point in the history
Bug fix: pubsub message's data and label fields missing in publishRaw().
  • Loading branch information
stephenplusplus committed Dec 15, 2014
2 parents 4293636 + f97caca commit af986b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/pubsub/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,11 @@ Topic.prototype.publishRaw = function(message, callback) {
if (!util.is(message.data, 'string') && !util.is(message.data, 'buffer')) {
message.data = new Buffer(JSON.stringify(message.data)).toString('base64');
}
message.topic = this.name;
this.makeReq_('POST', 'topics/publish', null, message, callback);
var body = {
message: message,
topic: this.name
};
this.makeReq_('POST', 'topics/publish', null, body, callback);
};

/**
Expand Down
4 changes: 2 additions & 2 deletions test/pubsub/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe('Topic', function() {

it('should stringify non-strings & non-buffers', function(done) {
topic.makeReq_ = function(method, path, qs, body) {
assert.deepEqual(body.data, messageObjDecoded);
assert.deepEqual(body.message.data, messageObjDecoded);
done();
};
topic.publishRaw({ data: messageObj }, assert.ifError);
Expand All @@ -160,7 +160,7 @@ describe('Topic', function() {
topic.makeReq_ = function(method, path, qs, body) {
assert.equal(method, 'POST');
assert.equal(path, 'topics/publish');
assert.deepEqual(body.message, messageRaw.message);
assert.deepEqual(body.message.data, messageRaw.data);
done();
};
topic.publishRaw(messageRaw, assert.ifError);
Expand Down

0 comments on commit af986b7

Please sign in to comment.