mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 12:21:36 +03:00
Redirect setup if authenticated
closes #3145 - added beforeModel redirect - added test
This commit is contained in:
parent
9214f25dee
commit
b332e8c158
@ -2,7 +2,12 @@ import styleBody from 'ghost/mixins/style-body';
|
|||||||
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
var SetupRoute = Ember.Route.extend(styleBody, loadingIndicator, {
|
var SetupRoute = Ember.Route.extend(styleBody, loadingIndicator, {
|
||||||
classNames: ['ghost-setup']
|
classNames: ['ghost-setup'],
|
||||||
|
beforeModel: function () {
|
||||||
|
if (this.get('session').isAuthenticated) {
|
||||||
|
this.transitionTo(Ember.SimpleAuth.routeAfterAuthentication);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default SetupRoute;
|
export default SetupRoute;
|
||||||
|
@ -100,6 +100,10 @@ screens = {
|
|||||||
'setup': {
|
'setup': {
|
||||||
url: 'ghost/setup/',
|
url: 'ghost/setup/',
|
||||||
selector: '.button-add'
|
selector: '.button-add'
|
||||||
|
},
|
||||||
|
'setup-authenticated': {
|
||||||
|
url: 'ghost/setup/',
|
||||||
|
selector: '#main-menu .content.active'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,3 +32,32 @@ CasperTest.begin('Ghost setup fails properly', 5, function suite(test) {
|
|||||||
test.assert(false, 'No error notification :(');
|
test.assert(false, 'No error notification :(');
|
||||||
});
|
});
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
CasperTest.begin('Authenticated user is redirected', 8, function suite(test) {
|
||||||
|
casper.thenOpenAndWaitForPageLoad('signin', function testTitleAndUrl() {
|
||||||
|
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
||||||
|
test.assertUrlMatch(/ghost\/signin\/$/, 'Landed on the correct URL');
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.waitForOpaque('.login-box', function then() {
|
||||||
|
this.fillAndSave('#login', user);
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.wait(2000);
|
||||||
|
|
||||||
|
casper.waitForResource(/posts/, function testForDashboard() {
|
||||||
|
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
||||||
|
test.assertExists('#global-header', 'Global admin header is present');
|
||||||
|
test.assertExists('.manage', 'We\'re now on content');
|
||||||
|
}, function onTimeOut() {
|
||||||
|
test.fail('Failed to signin');
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.thenOpenAndWaitForPageLoad('setup-authenticated', function testTitleAndUrl() {
|
||||||
|
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
||||||
|
test.assertExists('#global-header', 'Global admin header is present');
|
||||||
|
test.assertExists('.manage', 'We\'re now on content');
|
||||||
|
}, function onTimeOut() {
|
||||||
|
test.fail('Failed to redirect');
|
||||||
|
});
|
||||||
|
}, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user