Removed usage of /configuration/timezones/ endpoint

no issue
- replaced timezones endpoint with `@tryghost/timezone-data` module
This commit is contained in:
Kevin Ansfield 2019-02-26 12:37:50 +07:00
parent 1e36955ea4
commit 35860fad70
6 changed files with 12 additions and 49 deletions

View File

@ -1,6 +1,7 @@
import Ember from 'ember'; import Ember from 'ember';
import RSVP from 'rsvp'; import RSVP from 'rsvp';
import Service, {inject as service} from '@ember/service'; import Service, {inject as service} from '@ember/service';
import timezoneData from '@tryghost/timezone-data';
import {computed} from '@ember/object'; import {computed} from '@ember/object';
// ember-cli-shims doesn't export _ProxyMixin // ember-cli-shims doesn't export _ProxyMixin
@ -55,15 +56,7 @@ export default Service.extend(_ProxyMixin, {
}, },
availableTimezones: computed(function () { availableTimezones: computed(function () {
let timezonesUrl = this.ghostPaths.url.api('configuration', 'timezones'); return RSVP.resolve(timezoneData);
return this.ajax.request(timezonesUrl).then((configTimezones) => {
let [timezonesObj] = configTimezones.configuration;
timezonesObj = timezonesObj.timezones;
return timezonesObj;
});
}), }),
blogDomain: computed('blogUrl', function () { blogDomain: computed('blogUrl', function () {

View File

@ -21,16 +21,4 @@ export default function mockConfig(server) {
config: db.configs.find(1) config: db.configs.find(1)
}; };
}); });
server.get('/configuration/timezones/', function ({db}) {
if (isEmpty(db.timezones)) {
server.loadFixtures('timezones');
}
return {
configuration: [{
timezones: db.timezones
}]
};
});
} }

View File

@ -30,6 +30,7 @@
"@ember/optional-features": "0.7.0", "@ember/optional-features": "0.7.0",
"@html-next/vertical-collection": "1.0.0-beta.12", "@html-next/vertical-collection": "1.0.0-beta.12",
"@tryghost/mobiledoc-kit": "0.11.1-ghost.6", "@tryghost/mobiledoc-kit": "0.11.1-ghost.6",
"@tryghost/timezone-data": "0.1.1",
"autoprefixer": "9.4.8", "autoprefixer": "9.4.8",
"blueimp-md5": "2.10.0", "blueimp-md5": "2.10.0",
"broccoli-asset-rev": "3.0.0", "broccoli-asset-rev": "3.0.0",

View File

@ -67,7 +67,7 @@ describe('Acceptance: Error Handling', function () {
}); });
it('displays alert and aborts the transition when an ember-ajax error is thrown whilst navigating', async function () { it('displays alert and aborts the transition when an ember-ajax error is thrown whilst navigating', async function () {
this.server.get('/configuration/timezones/', versionMismatchResponse); this.server.get('/settings/', versionMismatchResponse);
await visit('/settings/tags'); await visit('/settings/tags');
await click('[data-test-nav="settings"]'); await click('[data-test-nav="settings"]');

View File

@ -4,29 +4,6 @@ import {describe, it} from 'mocha';
import {expect} from 'chai'; import {expect} from 'chai';
import {setupTest} from 'ember-mocha'; import {setupTest} from 'ember-mocha';
function stubAvailableTimezonesEndpoint(server) {
server.get('/ghost/api/v2/admin/configuration/timezones', function () {
return [
200,
{'Content-Type': 'application/json'},
JSON.stringify({
configuration: [{
timezones: [{
label: '(GMT -11:00) Midway Island, Samoa',
name: 'Pacific/Pago_Pago',
offset: -660
},
{
label: '(GMT) Greenwich Mean Time : Dublin, Edinburgh, London',
name: 'Europe/Dublin',
offset: 0
}]
}]
})
];
});
}
describe('Integration: Service: config', function () { describe('Integration: Service: config', function () {
setupTest('service:config', { setupTest('service:config', {
integration: true integration: true
@ -44,14 +21,13 @@ describe('Integration: Service: config', function () {
it('returns a list of timezones in the expected format', function (done) { it('returns a list of timezones in the expected format', function (done) {
let service = this.subject(); let service = this.subject();
stubAvailableTimezonesEndpoint(server);
service.get('availableTimezones').then(function (timezones) { service.get('availableTimezones').then(function (timezones) {
expect(timezones.length).to.equal(2); expect(timezones.length).to.equal(66);
expect(timezones[0].name).to.equal('Pacific/Pago_Pago'); expect(timezones[0].name).to.equal('Pacific/Pago_Pago');
expect(timezones[0].label).to.equal('(GMT -11:00) Midway Island, Samoa'); expect(timezones[0].label).to.equal('(GMT -11:00) Midway Island, Samoa');
expect(timezones[1].name).to.equal('Europe/Dublin'); expect(timezones[1].name).to.equal('Pacific/Honolulu');
expect(timezones[1].label).to.equal('(GMT) Greenwich Mean Time : Dublin, Edinburgh, London'); expect(timezones[1].label).to.equal('(GMT -10:00) Hawaii');
done(); done();
}); });
}); });

View File

@ -713,6 +713,11 @@
mobiledoc-dom-renderer "0.6.5" mobiledoc-dom-renderer "0.6.5"
mobiledoc-text-renderer "0.3.2" mobiledoc-text-renderer "0.3.2"
"@tryghost/timezone-data@0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@tryghost/timezone-data/-/timezone-data-0.1.1.tgz#4ae120de518f6d5b81d16177bbc7fcd159d5c925"
integrity sha512-6cJHmh7PkhRYgzi46xS37HGR4uZ/pCmfzsATZFZP3BtP16PpgOfH0J3D0Q8wP1GM0C7OTRKhtyqfUaLS/RkSJA==
"@types/acorn@^4.0.3": "@types/acorn@^4.0.3":
version "4.0.4" version "4.0.4"
resolved "https://registry.yarnpkg.com/@types/acorn/-/acorn-4.0.4.tgz#b3ee72dcd81d1daeea03fed67d7ca7c2574c313b" resolved "https://registry.yarnpkg.com/@types/acorn/-/acorn-4.0.4.tgz#b3ee72dcd81d1daeea03fed67d7ca7c2574c313b"