diff --git a/core/client/routes/setup.js b/core/client/routes/setup.js index 849c39b157..bebcdfefa4 100644 --- a/core/client/routes/setup.js +++ b/core/client/routes/setup.js @@ -2,7 +2,12 @@ import styleBody from 'ghost/mixins/style-body'; import loadingIndicator from 'ghost/mixins/loading-indicator'; 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; diff --git a/core/test/functional/base.js b/core/test/functional/base.js index 1cc4009fe7..b56987a894 100644 --- a/core/test/functional/base.js +++ b/core/test/functional/base.js @@ -100,6 +100,10 @@ screens = { 'setup': { url: 'ghost/setup/', selector: '.button-add' + }, + 'setup-authenticated': { + url: 'ghost/setup/', + selector: '#main-menu .content.active' } }; diff --git a/core/test/functional/client/setup_test.js b/core/test/functional/client/setup_test.js index 8fff538685..91a22239e9 100644 --- a/core/test/functional/client/setup_test.js +++ b/core/test/functional/client/setup_test.js @@ -31,4 +31,33 @@ CasperTest.begin('Ghost setup fails properly', 5, function suite(test) { }, function onTimeout() { test.assert(false, 'No error notification :('); }); -}, true); \ No newline at end of file +}, 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);