mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 09:03:12 +03:00
Removed usage of /configuration/timezones/ endpoint
no issue - replaced timezones endpoint with `@tryghost/timezone-data` module
This commit is contained in:
parent
1e36955ea4
commit
35860fad70
@ -1,6 +1,7 @@
|
||||
import Ember from 'ember';
|
||||
import RSVP from 'rsvp';
|
||||
import Service, {inject as service} from '@ember/service';
|
||||
import timezoneData from '@tryghost/timezone-data';
|
||||
import {computed} from '@ember/object';
|
||||
|
||||
// ember-cli-shims doesn't export _ProxyMixin
|
||||
@ -55,15 +56,7 @@ export default Service.extend(_ProxyMixin, {
|
||||
},
|
||||
|
||||
availableTimezones: computed(function () {
|
||||
let timezonesUrl = this.ghostPaths.url.api('configuration', 'timezones');
|
||||
|
||||
return this.ajax.request(timezonesUrl).then((configTimezones) => {
|
||||
let [timezonesObj] = configTimezones.configuration;
|
||||
|
||||
timezonesObj = timezonesObj.timezones;
|
||||
|
||||
return timezonesObj;
|
||||
});
|
||||
return RSVP.resolve(timezoneData);
|
||||
}),
|
||||
|
||||
blogDomain: computed('blogUrl', function () {
|
||||
|
@ -21,16 +21,4 @@ export default function mockConfig(server) {
|
||||
config: db.configs.find(1)
|
||||
};
|
||||
});
|
||||
|
||||
server.get('/configuration/timezones/', function ({db}) {
|
||||
if (isEmpty(db.timezones)) {
|
||||
server.loadFixtures('timezones');
|
||||
}
|
||||
|
||||
return {
|
||||
configuration: [{
|
||||
timezones: db.timezones
|
||||
}]
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
"@ember/optional-features": "0.7.0",
|
||||
"@html-next/vertical-collection": "1.0.0-beta.12",
|
||||
"@tryghost/mobiledoc-kit": "0.11.1-ghost.6",
|
||||
"@tryghost/timezone-data": "0.1.1",
|
||||
"autoprefixer": "9.4.8",
|
||||
"blueimp-md5": "2.10.0",
|
||||
"broccoli-asset-rev": "3.0.0",
|
||||
|
@ -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 () {
|
||||
this.server.get('/configuration/timezones/', versionMismatchResponse);
|
||||
this.server.get('/settings/', versionMismatchResponse);
|
||||
|
||||
await visit('/settings/tags');
|
||||
await click('[data-test-nav="settings"]');
|
||||
|
@ -4,29 +4,6 @@ import {describe, it} from 'mocha';
|
||||
import {expect} from 'chai';
|
||||
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 () {
|
||||
setupTest('service:config', {
|
||||
integration: true
|
||||
@ -44,14 +21,13 @@ describe('Integration: Service: config', function () {
|
||||
|
||||
it('returns a list of timezones in the expected format', function (done) {
|
||||
let service = this.subject();
|
||||
stubAvailableTimezonesEndpoint(server);
|
||||
|
||||
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].label).to.equal('(GMT -11:00) Midway Island, Samoa');
|
||||
expect(timezones[1].name).to.equal('Europe/Dublin');
|
||||
expect(timezones[1].label).to.equal('(GMT) Greenwich Mean Time : Dublin, Edinburgh, London');
|
||||
expect(timezones[1].name).to.equal('Pacific/Honolulu');
|
||||
expect(timezones[1].label).to.equal('(GMT -10:00) Hawaii');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -713,6 +713,11 @@
|
||||
mobiledoc-dom-renderer "0.6.5"
|
||||
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":
|
||||
version "4.0.4"
|
||||
resolved "https://registry.yarnpkg.com/@types/acorn/-/acorn-4.0.4.tgz#b3ee72dcd81d1daeea03fed67d7ca7c2574c313b"
|
||||
|
Loading…
Reference in New Issue
Block a user