2014-03-14 17:10:50 -05:00
|
|
|
/*globals describe, beforeEach, afterEach, it*/
|
2014-06-04 16:26:03 -05:00
|
|
|
/*jshint expr:true*/
|
|
|
|
var nock = require('nock'),
|
|
|
|
settings = require('../../server/api').settings,
|
2014-03-14 17:10:50 -05:00
|
|
|
should = require('should'),
|
|
|
|
sinon = require('sinon'),
|
|
|
|
testUtils = require('../utils'),
|
2014-08-17 01:17:23 -05:00
|
|
|
Promise = require('bluebird'),
|
2014-03-14 17:10:50 -05:00
|
|
|
xmlrpc = require('../../server/xmlrpc'),
|
|
|
|
// storing current environment
|
|
|
|
currentEnv = process.env.NODE_ENV;
|
|
|
|
|
2014-06-04 16:26:03 -05:00
|
|
|
// To stop jshint complaining
|
|
|
|
should.equal(true, true);
|
|
|
|
|
2014-03-14 17:10:50 -05:00
|
|
|
describe('XMLRPC', function () {
|
|
|
|
var sandbox;
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
sandbox = sinon.sandbox.create();
|
|
|
|
// give environment a value that will ping
|
2014-06-04 16:26:03 -05:00
|
|
|
process.env.NODE_ENV = 'production';
|
2014-03-14 17:10:50 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
sandbox.restore();
|
|
|
|
// reset the environment
|
|
|
|
process.env.NODE_ENV = currentEnv;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should execute two pings', function (done) {
|
|
|
|
var ping1 = nock('http://blogsearch.google.com').post('/ping/RPC2').reply(200),
|
|
|
|
ping2 = nock('http://rpc.pingomatic.com').post('/').reply(200),
|
|
|
|
testPost = testUtils.DataGenerator.Content.posts[2],
|
|
|
|
settingsStub = sandbox.stub(settings, 'read', function () {
|
2014-09-09 23:06:24 -05:00
|
|
|
return Promise.resolve({settings: [{value: '/:slug/'}]});
|
2014-03-14 17:10:50 -05:00
|
|
|
});
|
2014-06-04 16:26:03 -05:00
|
|
|
/*jshint unused:false */
|
2014-03-14 17:10:50 -05:00
|
|
|
|
|
|
|
xmlrpc.ping(testPost).then(function () {
|
|
|
|
ping1.isDone().should.be.true;
|
|
|
|
ping2.isDone().should.be.true;
|
|
|
|
|
|
|
|
done();
|
2014-05-05 15:58:58 -05:00
|
|
|
}).catch(done);
|
2014-03-14 17:10:50 -05:00
|
|
|
});
|
|
|
|
});
|