From c3bb7cb396bdaa546eed3b502a11c9b48d21995d Mon Sep 17 00:00:00 2001 From: cobbspur Date: Mon, 25 May 2015 17:00:42 +0100 Subject: [PATCH] Fix route for About page No Issue - Routes, views and controllers updated for about page - fix up tests and add redirect check --- .../app/controllers/{settings => }/about.js | 4 +- core/client/app/router.js | 2 + core/client/app/routes/about.js | 35 +++++++++++++++++ core/client/app/routes/settings/about.js | 28 +------------- .../app/templates/{settings => }/about.hbs | 2 +- core/client/app/views/about.js | 5 +++ core/client/app/views/settings/about.js | 5 --- core/test/functional/base.js | 5 +++ core/test/functional/client/about_test.js | 38 +++++++++++++++++++ .../functional/client/settings_about_test.js | 36 ++---------------- 10 files changed, 94 insertions(+), 66 deletions(-) rename core/client/app/controllers/{settings => }/about.js (68%) create mode 100644 core/client/app/routes/about.js rename core/client/app/templates/{settings => }/about.hbs (94%) create mode 100644 core/client/app/views/about.js delete mode 100644 core/client/app/views/settings/about.js create mode 100644 core/test/functional/client/about_test.js diff --git a/core/client/app/controllers/settings/about.js b/core/client/app/controllers/about.js similarity index 68% rename from core/client/app/controllers/settings/about.js rename to core/client/app/controllers/about.js index c8bb28ebc3..365ceefd40 100644 --- a/core/client/app/controllers/settings/about.js +++ b/core/client/app/controllers/about.js @@ -1,5 +1,5 @@ import Ember from 'ember'; -var SettingsAboutController = Ember.Controller.extend({ +var AboutController = Ember.Controller.extend({ updateNotificationCount: 0, actions: { @@ -9,4 +9,4 @@ var SettingsAboutController = Ember.Controller.extend({ } }); -export default SettingsAboutController; +export default AboutController; diff --git a/core/client/app/router.js b/core/client/app/router.js index 27b93e9d01..615df78d4f 100644 --- a/core/client/app/router.js +++ b/core/client/app/router.js @@ -20,6 +20,7 @@ Router.map(function () { this.route('signout'); this.route('signup', {path: '/signup/:token'}); this.route('reset', {path: '/reset/:token'}); + this.route('about', {path: '/about'}); this.resource('posts', {path: '/'}, function () { this.route('post', {path: ':post_id'}); @@ -37,6 +38,7 @@ Router.map(function () { this.route('user', {path: '/:slug'}); }); + // Redirect about page this.route('about'); this.route('tags'); this.route('labs'); diff --git a/core/client/app/routes/about.js b/core/client/app/routes/about.js new file mode 100644 index 0000000000..ff6c1d2f57 --- /dev/null +++ b/core/client/app/routes/about.js @@ -0,0 +1,35 @@ +import AuthenticatedRoute from 'ghost/routes/authenticated'; +import loadingIndicator from 'ghost/mixins/loading-indicator'; +import styleBody from 'ghost/mixins/style-body'; + +var AboutRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, { + titleToken: 'About', + + classNames: ['view-about'], + + cachedConfig: false, + model: function () { + var cachedConfig = this.get('cachedConfig'), + self = this; + if (cachedConfig) { + return cachedConfig; + } + + return ic.ajax.request(this.get('ghostPaths.url').api('configuration')) + .then(function (configurationResponse) { + var configKeyValues = configurationResponse.configuration; + cachedConfig = {}; + configKeyValues.forEach(function (configKeyValue) { + cachedConfig[configKeyValue.key] = configKeyValue.value; + }); + self.set('cachedConfig', cachedConfig); + return cachedConfig; + }); + }, + + renderTemplate: function () { + this.render('about', {into: 'application'}); + } +}); + +export default AboutRoute; diff --git a/core/client/app/routes/settings/about.js b/core/client/app/routes/settings/about.js index 1e166742a5..447b1ee666 100644 --- a/core/client/app/routes/settings/about.js +++ b/core/client/app/routes/settings/about.js @@ -3,32 +3,8 @@ import loadingIndicator from 'ghost/mixins/loading-indicator'; import styleBody from 'ghost/mixins/style-body'; var SettingsAboutRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, { - titleToken: 'About', - - classNames: ['settings-view-about'], - - cachedConfig: false, - model: function () { - var cachedConfig = this.get('cachedConfig'), - self = this; - if (cachedConfig) { - return cachedConfig; - } - - return ic.ajax.request(this.get('ghostPaths.url').api('configuration')) - .then(function (configurationResponse) { - var configKeyValues = configurationResponse.configuration; - cachedConfig = {}; - configKeyValues.forEach(function (configKeyValue) { - cachedConfig[configKeyValue.key] = configKeyValue.value; - }); - self.set('cachedConfig', cachedConfig); - return cachedConfig; - }); - }, - - renderTemplate: function () { - this.render('settings/about', {into: 'application'}); + beforeModel: function () { + this.transitionTo('about'); } }); diff --git a/core/client/app/templates/settings/about.hbs b/core/client/app/templates/about.hbs similarity index 94% rename from core/client/app/templates/settings/about.hbs rename to core/client/app/templates/about.hbs index fe0d4b8f83..cc3e9814cb 100644 --- a/core/client/app/templates/settings/about.hbs +++ b/core/client/app/templates/about.hbs @@ -3,7 +3,7 @@
- {{gh-notifications location="settings-about-upgrade" notify="updateNotificationChange"}} + {{gh-notifications location="about-upgrade" notify="updateNotificationChange"}}
diff --git a/core/client/app/views/about.js b/core/client/app/views/about.js new file mode 100644 index 0000000000..ca97178f90 --- /dev/null +++ b/core/client/app/views/about.js @@ -0,0 +1,5 @@ +import BaseView from 'ghost/views/settings/content-base'; + +var AboutView = BaseView.extend(); + +export default AboutView; diff --git a/core/client/app/views/settings/about.js b/core/client/app/views/settings/about.js deleted file mode 100644 index 032be3076e..0000000000 --- a/core/client/app/views/settings/about.js +++ /dev/null @@ -1,5 +0,0 @@ -import BaseView from 'ghost/views/settings/content-base'; - -var SettingsAboutView = BaseView.extend(); - -export default SettingsAboutView; diff --git a/core/test/functional/base.js b/core/test/functional/base.js index 76b5b674b6..b8026db3b7 100644 --- a/core/test/functional/base.js +++ b/core/test/functional/base.js @@ -75,6 +75,11 @@ screens = { linkSelector: '.gh-nav-main-editor', selector: '.gh-nav-main-editor.active' }, + about: { + url: 'ghost/settings/about', + linkSelector: '.gh-nav-menu-about', + selector: '.gh-about-header' + }, 'editor.editing': { url: 'ghost/editor/', linkSelector: 'a.post-edit', diff --git a/core/test/functional/client/about_test.js b/core/test/functional/client/about_test.js new file mode 100644 index 0000000000..a7e02b4ad3 --- /dev/null +++ b/core/test/functional/client/about_test.js @@ -0,0 +1,38 @@ +// # About Test +// Test the various parts of the About page + +/*globals CasperTest, casper */ + +CasperTest.begin('About screen is correct', 9, function suite(test) { + casper.thenOpenAndWaitForPageLoad('about', function testTitleAndUrl() { + test.assertTitle('About - Test Blog', 'Ghost admin has incorrect title'); + test.assertUrlMatch(/ghost\/about\/$/, 'Redirected to the correct URL'); + }); + + casper.then(function testVersionNumber() { + var versionNumber = casper.getHTML('.gh-env-list-version'); + test.assertMatch(versionNumber, /\d+\.\d+\.\d+/, 'Version is a number'); // Tests for a pattern like 0.0.0 to v11111.3334534.2342453-beta + }); + + casper.then(function testDatabaseType() { + var databaseTypeText = casper.getHTML('.gh-env-list-database-type'); + test.assertMatch(databaseTypeText, /sqlite3|mysql|pg/gi, 'Database is an allowed type'); + }); + + casper.waitForSelector('.gh-contributors article', function testContributors() { + var firstContribImageSrc = casper.getElementAttribute('.gh-contributors article:nth-child(1) a img', 'src'); + + // Check first contributor image tag is on the page + test.assertExist('.gh-contributors article:nth-child(1) img', 'First contributor image is in place'); + + // Check first contributor image resource exists & alt tag isnt empty + test.assertResourceExists(firstContribImageSrc, 'First contributor image file exists'); + test.assertDoesntExist('.gh-contributors article:nth-child(1) a img[alt=""]', 'First contributor image alt is not empty'); + + // Check first contributor links to GitHub + test.assertExists('.gh-contributors article:nth-child(1) a[href*="github.com"]', 'First contributor link to GitHub'); + + // Check first contributor links to GitHub + test.assertDoesntExist('.gh-contributors article:nth-child(1) a[title=""]', 'First contributor title is not empty'); + }); +}); diff --git a/core/test/functional/client/settings_about_test.js b/core/test/functional/client/settings_about_test.js index 94860d4056..4dcde4581d 100644 --- a/core/test/functional/client/settings_about_test.js +++ b/core/test/functional/client/settings_about_test.js @@ -1,38 +1,10 @@ -// # About Test -// Test the various parts of the About page +// # Settings About Test +// Tests that the settings about page is redirected /*globals CasperTest, casper */ -CasperTest.begin('About screen is correct', 9, function suite(test) { +CasperTest.begin('About screen is correct', 1, function suite(test) { casper.thenOpenAndWaitForPageLoad('settings.about', function testTitleAndUrl() { - test.assertTitle('Settings - About - Test Blog', 'Ghost admin has incorrect title'); - test.assertUrlMatch(/ghost\/settings\/about\/$/, 'Landed on the correct URL'); - }); - - casper.then(function testVersionNumber() { - var versionNumber = casper.getHTML('.gh-env-list-version'); - test.assertMatch(versionNumber, /\d+\.\d+\.\d+/, 'Version is a number'); // Tests for a pattern like 0.0.0 to v11111.3334534.2342453-beta - }); - - casper.then(function testDatabaseType() { - var databaseTypeText = casper.getHTML('.gh-env-list-database-type'); - test.assertMatch(databaseTypeText, /sqlite3|mysql|pg/gi, 'Database is an allowed type'); - }); - - casper.waitForSelector('.gh-contributors article', function testContributors() { - var firstContribImageSrc = casper.getElementAttribute('.gh-contributors article:nth-child(1) a img', 'src'); - - // Check first contributor image tag is on the page - test.assertExist('.gh-contributors article:nth-child(1) img', 'First contributor image is in place'); - - // Check first contributor image resource exists & alt tag isnt empty - test.assertResourceExists(firstContribImageSrc, 'First contributor image file exists'); - test.assertDoesntExist('.gh-contributors article:nth-child(1) a img[alt=""]', 'First contributor image alt is not empty'); - - // Check first contributor links to GitHub - test.assertExists('.gh-contributors article:nth-child(1) a[href*="github.com"]', 'First contributor link to GitHub'); - - // Check first contributor links to GitHub - test.assertDoesntExist('.gh-contributors article:nth-child(1) a[title=""]', 'First contributor title is not empty'); + test.assertUrlMatch(/ghost\/about\/$/, 'Redirected to the correct URL'); }); });