Skip to content

Commit b22d140

Browse files
committed
Handle posts having no links
1 parent c29179a commit b22d140

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

lib/webmention.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ module.exports = function createWebmentionDispatcher(_log, db) {
8686
}
8787
});
8888
});
89+
90+
if (jobs === 0) {
91+
log.debug('Nothing to do; completed Webmention processing.');
92+
process.nextTick(cb);
93+
}
8994
});
9095
};
9196
};

test/z-webmention-test.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ var vows = require('perjury'),
5555
wrapFsMocks = persistenceutil.wrapFsMocks,
5656
data = {
5757
singleLink: '<a href="http://nicenice.website/blag/new-puppy">So cute!</a>',
58-
multipleLinks: '<a href="http://magic.geek/pics/another-doggo">Even cuter!</a> I love <a href="http://catscatscats.org/">cats</a> too!'
58+
multipleLinks: '<a href="http://magic.geek/pics/another-doggo">Even cuter!</a> I love <a href="http://catscatscats.org/">cats</a> too!',
59+
noLinks: 'I have absolutely no links at all.'
5960
};
6061

6162
var clock;
@@ -183,9 +184,29 @@ vows.describe('Webmention module').addBatch({
183184
var spy = fns[0];
184185
assert.equal(spy.callCount, 4);
185186
// XXX args
187+
},
188+
'and we call the module with a post that has no links at all': {
189+
topic: function(fns) {
190+
var webmention = fns[1],
191+
cb = this.callback;
192+
193+
webmention('http://ordinary.net/bland_post',
194+
200,
195+
data.noLinks,
196+
function(err) {
197+
cb(err, fns);
198+
});
199+
},
200+
'it works': function(err) {
201+
assert.ifError(err);
202+
},
203+
'the spy wasn\'t called again': function(err, fns) {
204+
var spy = fns[0];
205+
assert.equal(spy.callCount, 4);
206+
// XXX args
207+
}
186208
}
187209
}
188-
189210
}
190211
}
191212
}

0 commit comments

Comments
 (0)