0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-08 02:52:39 -05:00

🐛 Fixed only save imported post ids if amp field is empty (#8967)

closes #8963

- if an LTS export is imported into a 1.0 blog, then the 1.0 blog is
exported and re-imported into another 1.0 blog, any post ids from the
lts import were getting clobbered. This only saves the post id if the
amp field does not already exist
- add failing test that passes w/change
This commit is contained in:
Austin Burdine 2017-09-04 03:48:56 -04:00 committed by Katharina Irrgang
parent 2ecf06da52
commit a9e668a949
3 changed files with 1564 additions and 1 deletions

View file

@ -139,7 +139,10 @@ class PostsImporter extends BaseImporter {
}
// NOTE: we remember the old post id for disqus
if (model.id) {
// We also check if amp already exists to prevent
// overwriting any comment ids from a 1.0 export
// (see https://github.com/TryGhost/Ghost/issues/8963)
if (model.id && !model.amp) {
model.amp = model.id.toString();
}
});

View file

@ -1450,6 +1450,8 @@ describe('Import (new test structure)', function () {
// Check post language is null
should(firstPost.locale).equal(null);
// Check post id has been inserted into amp column
should(firstPost.amp).equal(exportData.data.posts[0].id.toString());
// Check user language is null
should(users[1].locale).equal(null);
@ -1658,4 +1660,30 @@ describe('Import (new test structure)', function () {
}).catch(done);
});
});
describe('1.0: basic import test', function () {
var exportData;
before(function doImport() {
// initialize the blog with some data
return testUtils.initFixtures('roles', 'owner', 'settings').then(function () {
return testUtils.fixtures.loadExportFixture('export-basic-test');
}).then(function (exported) {
exportData = exported.db[0];
return dataImporter.doImport(exportData);
});
});
after(testUtils.teardown);
it('keeps the value of the amp field', function () {
return knex('posts').select().then(function (posts) {
should.exist(posts);
posts.length.should.eql(exportData.data.posts.length);
posts[0].amp.should.eql(exportData.data.posts[0].amp);
posts[1].amp.should.eql(exportData.data.posts[1].id);
});
});
});
});

File diff suppressed because it is too large Load diff