Ghost/core/test/unit/xmlrpc_spec.js
Jacob Gable 7e9880ce8d Settings API Primary Document refactor
Closes #2606

- Refactor settings api responses to { settings: [ ] } format
- Update all code using api.settings to handle new response format
- Update test stubs to return new format
- Update client site settings model to parse new format into one object of key/value pairs
- Refactor to include all setting values
- Remove unused settingsCollection method
- Update settingsCache to store all attributes
- Update settingsResult to send all attributes
- Remove unnecessary when() wraps
- Reject if editing a setting that doesn't exist
- Reject earlier if setting key is empty
- Update tests with new error messages
- Use setting.add instead of edit that was incorrectly adding
- Update importer to properly import activePlugins and installedPlugins
- Update expected setting result fields
- Fix a weird situation where hasOwnProperty didn't exist 🤷
2014-04-30 23:15:27 -05:00

47 lines
1.5 KiB
JavaScript

/*globals describe, beforeEach, afterEach, it*/
var assert = require('assert'),
http = require('http'),
nock = require('nock'),
settings = require('../../server/api').settings;
should = require('should'),
sinon = require('sinon'),
testUtils = require('../utils'),
when = require('when'),
xmlrpc = require('../../server/xmlrpc'),
// storing current environment
currentEnv = process.env.NODE_ENV;
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 (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 () {
return when({ settings: [{value: '/:slug/'}] });
});
xmlrpc.ping(testPost).then(function () {
ping1.isDone().should.be.true;
ping2.isDone().should.be.true;
done();
});
});
});