mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Merge pull request #3767 from jaswilli/clear-ws-slug
This commit is contained in:
commit
6c96d00bcc
2 changed files with 51 additions and 2 deletions
|
@ -152,6 +152,9 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
|
||||||
|
|
||||||
// Ignore unchanged slugs or candidate slugs that are empty
|
// Ignore unchanged slugs or candidate slugs that are empty
|
||||||
if (!newSlug || slug === newSlug) {
|
if (!newSlug || slug === newSlug) {
|
||||||
|
// reset the input to its previous state
|
||||||
|
this.set('slugValue', slug);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,6 +179,8 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
|
||||||
// for the incrementor then the existing slug should be used
|
// for the incrementor then the existing slug should be used
|
||||||
if (_.isNumber(check) && check > 0) {
|
if (_.isNumber(check) && check > 0) {
|
||||||
if (slug === slugTokens.join('-') && serverSlug !== newSlug) {
|
if (slug === slugTokens.join('-') && serverSlug !== newSlug) {
|
||||||
|
self.set('slugValue', slug);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,9 +198,11 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.get('model').save(self.get('saveOptions'));
|
return self.get('model').save(self.get('saveOptions'));
|
||||||
}).then(function () {
|
}).then(function (changed) {
|
||||||
self.showSuccess('Permalink successfully changed to <strong>' +
|
if (changed) {
|
||||||
|
self.showSuccess('Permalink successfully changed to <strong>' +
|
||||||
self.get('slug') + '</strong>.');
|
self.get('slug') + '</strong>.');
|
||||||
|
}
|
||||||
}).catch(function (errors) {
|
}).catch(function (errors) {
|
||||||
self.showErrors(errors);
|
self.showErrors(errors);
|
||||||
self.get('model').rollback();
|
self.get('model').rollback();
|
||||||
|
|
|
@ -225,4 +225,46 @@ CasperTest.begin('Post can be changed to static page', 6, function suite(test) {
|
||||||
|
|
||||||
test.assertDoesntExist('.post-setting-static-page:checked', 'can turn off static page');
|
test.assertDoesntExist('.post-setting-static-page:checked', 'can turn off static page');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
CasperTest.begin('Post url input is reset from all whitespace back to original value', 3, function suite(test) {
|
||||||
|
// Create a sample post
|
||||||
|
CasperTest.Routines.createTestPost.run(false);
|
||||||
|
|
||||||
|
// Begin test
|
||||||
|
casper.thenOpenAndWaitForPageLoad('content', function testTitleAndUrl() {
|
||||||
|
test.assertTitle('Ghost Admin', 'Title is "Ghost Admin"');
|
||||||
|
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Transition to the editor
|
||||||
|
casper.thenClick('.post-edit');
|
||||||
|
casper.waitForSelector('#entry-title');
|
||||||
|
|
||||||
|
casper.thenClick('.post-settings');
|
||||||
|
casper.waitForOpaque('.post-settings-menu.open');
|
||||||
|
|
||||||
|
var originalSlug;
|
||||||
|
casper.then(function () {
|
||||||
|
originalSlug = casper.evaluate(function () {
|
||||||
|
return __utils__.getFieldValue('post-setting-slug');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Test change permalink
|
||||||
|
casper.then(function () {
|
||||||
|
this.fillSelectors('.post-settings-menu form', {
|
||||||
|
'#url': ' '
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
this.click('button.post-settings');
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.then(function checkValueMatches() {
|
||||||
|
//using assertField(name) checks the htmls initial "value" attribute, so have to hack around it.
|
||||||
|
var slugVal = this.evaluate(function () {
|
||||||
|
return __utils__.getFieldValue('post-setting-slug');
|
||||||
|
});
|
||||||
|
test.assertEqual(slugVal, originalSlug);
|
||||||
|
});
|
||||||
});
|
});
|
Loading…
Add table
Reference in a new issue