Skip to content

Commit

Permalink
Update client fixtures
Browse files Browse the repository at this point in the history
closes 4184
- update ghost-admin client
- add ghost-frontend client
  • Loading branch information
sebgie authored and ErisDS committed Sep 1, 2015
1 parent 34c888d commit d0b0335
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
9 changes: 9 additions & 0 deletions core/server/data/fixtures/fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@
{
"name": "Ghost Admin",
"slug": "ghost-admin",
"status": "enabled",
"type": "ua",
"secret": "not_available"
},
{
"name": "Ghost Frontend",
"slug": "ghost-frontend",
"status": "enabled",
"type": "ua",
"secret": "not_available"
}
]
Expand Down
36 changes: 30 additions & 6 deletions core/server/data/fixtures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,10 @@ to003 = function () {
logInfo('Upgrading fixtures to 003');

// Add the client fixture if missing
upgradeOp = Client.findOne({secret: fixtures.clients[0].secret}).then(function (client) {
upgradeOp = Client.findOne({slug: fixtures.clients[0].slug}).then(function (client) {
if (!client) {
logInfo('Adding client fixture');
_.each(fixtures.clients, function (client) {
return Client.add(client, options);
});
logInfo('Adding ghost-admin client fixture');
return Client.add(fixtures.clients[0], options);
}
});
ops.push(upgradeOp);
Expand Down Expand Up @@ -165,6 +163,8 @@ to003 = function () {
*/
to004 = function () {
var value,
ops = [],
upgradeOp,
jquery = [
'<!-- You can safely delete this line if your theme does not require jQuery -->\n',
'<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>\n\n'
Expand All @@ -176,7 +176,8 @@ to004 = function () {

logInfo('Upgrading fixtures to 004');

return models.Settings.findOne('ghost_foot').then(function (setting) {
// add jquery setting and privacy info
upgradeOp = models.Settings.findOne('ghost_foot').then(function (setting) {
if (setting) {
logInfo('Adding jQuery link to ghost_foot');
value = setting.attributes.value;
Expand All @@ -193,6 +194,29 @@ to004 = function () {
});
}
});
ops.push(upgradeOp);

// Update ghost-admin client fixture
// ghost-admin should exist from 003 version
upgradeOp = models.Client.findOne({slug: fixtures.clients[0].slug}).then(function (client) {
if (client) {
logInfo('Update ghost-admin client fixture');
return models.Client.edit(fixtures.clients[0], _.extend({}, options, {id: client.id}));
}
return Promise.resolve();
});
ops.push(upgradeOp);

// add ghost-frontend client if missing
upgradeOp = models.Client.findOne({slug: fixtures.clients[1].slug}).then(function (client) {
if (!client) {
logInfo('Add ghost-frontend client fixture');
return models.Client.add(fixtures.clients[1], options);
}
return Promise.resolve();
});
ops.push(upgradeOp);
return Promise.all(ops);
};

update = function (fromVersion, toVersion) {
Expand Down

0 comments on commit d0b0335

Please sign in to comment.