mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
196bbfce18
fixes #5104, refs #4348, #2263 - Create a centralised event module - Hook it up for posts, pages, tags and users - Use it in sitemaps instead of direct method calls - Use it for xmlrpc calls - Check events are fired in model tests - Update sitemap tests to work with new code - Fix a bug where invited users were appearing in sitemaps - Move sitemaps and xmlrpc into a directory together
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
/*globals describe, beforeEach, afterEach, it*/
|
|
/*jshint expr:true*/
|
|
var nock = require('nock'),
|
|
should = require('should'),
|
|
sinon = require('sinon'),
|
|
testUtils = require('../utils'),
|
|
xmlrpc = require('../../server/data/xml/xmlrpc'),
|
|
events = require('../../server/events'),
|
|
// storing current environment
|
|
currentEnv = process.env.NODE_ENV;
|
|
|
|
// To stop jshint complaining
|
|
should.equal(true, true);
|
|
|
|
describe('XMLRPC', function () {
|
|
var sandbox;
|
|
|
|
beforeEach(function () {
|
|
sandbox = sinon.sandbox.create();
|
|
// give environment a value that will ping
|
|
process.env.NODE_ENV = 'production';
|
|
});
|
|
|
|
afterEach(function () {
|
|
sandbox.restore();
|
|
// reset the environment
|
|
process.env.NODE_ENV = currentEnv;
|
|
});
|
|
|
|
it('should execute two pings', function () {
|
|
var ping1 = nock('http://blogsearch.google.com').post('/ping/RPC2').reply(200),
|
|
ping2 = nock('http://rpc.pingomatic.com').post('/').reply(200),
|
|
testPost = {
|
|
toJSON: function () {
|
|
return testUtils.DataGenerator.Content.posts[2];
|
|
}
|
|
};
|
|
|
|
xmlrpc.init();
|
|
events.emit('post.published', testPost);
|
|
ping1.isDone().should.be.true;
|
|
ping2.isDone().should.be.true;
|
|
});
|
|
});
|