2016-08-17 18:14:33 +03:00
|
|
|
import mockAuthentication from './config/authentication';
|
|
|
|
import mockPosts from './config/posts';
|
|
|
|
import mockRoles from './config/roles';
|
|
|
|
import mockSettings from './config/settings';
|
|
|
|
import mockSlugs from './config/slugs';
|
|
|
|
import mockSubscribers from './config/subscribers';
|
|
|
|
import mockTags from './config/tags';
|
|
|
|
import mockUsers from './config/users';
|
2015-10-13 16:52:41 +03:00
|
|
|
|
2016-08-17 18:14:33 +03:00
|
|
|
// import {versionMismatchResponse} from 'utils';
|
2016-04-15 17:45:50 +03:00
|
|
|
|
2015-10-13 16:52:41 +03:00
|
|
|
export default function () {
|
|
|
|
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
|
2016-07-31 22:47:19 +03:00
|
|
|
this.namespace = '/ghost/api/v0.1'; // make this `api`, for example, if your API is namespaced
|
2016-04-15 17:45:50 +03:00
|
|
|
this.timing = 400; // delay for each request, automatically set to 0 during testing
|
2015-10-13 16:52:41 +03:00
|
|
|
|
2016-04-13 12:44:09 +03:00
|
|
|
// Mock endpoints here to override real API requests during development
|
2016-06-30 17:45:02 +03:00
|
|
|
// this.put('/posts/:id/', versionMismatchResponse);
|
2016-08-17 18:14:33 +03:00
|
|
|
// mockSubscribers(this);
|
2016-04-13 12:44:09 +03:00
|
|
|
|
|
|
|
// keep this line, it allows all other API requests to hit the real server
|
|
|
|
this.passthrough();
|
|
|
|
|
|
|
|
// add any external domains to make sure those get passed through too
|
|
|
|
this.passthrough('https://count.ghost.org/');
|
|
|
|
this.passthrough('http://www.gravatar.com/**');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mock all endpoints here as there is no real API during testing
|
|
|
|
export function testConfig() {
|
|
|
|
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
|
2016-07-31 22:47:19 +03:00
|
|
|
this.namespace = '/ghost/api/v0.1'; // make this `api`, for example, if your API is namespaced
|
2016-04-13 12:44:09 +03:00
|
|
|
// this.timing = 400; // delay for each request, automatically set to 0 during testing
|
2016-07-22 16:36:50 +03:00
|
|
|
// this.logging = true;
|
2016-04-13 12:44:09 +03:00
|
|
|
|
2016-08-17 18:14:33 +03:00
|
|
|
mockAuthentication(this);
|
|
|
|
mockPosts(this);
|
|
|
|
mockRoles(this);
|
|
|
|
mockSettings(this);
|
|
|
|
mockSlugs(this);
|
|
|
|
mockSubscribers(this);
|
|
|
|
mockTags(this);
|
|
|
|
mockUsers(this);
|
2015-11-13 14:48:59 +03:00
|
|
|
|
2015-10-13 16:52:41 +03:00
|
|
|
/* Notifications -------------------------------------------------------- */
|
|
|
|
|
|
|
|
this.get('/notifications/', 'notifications');
|
|
|
|
|
2016-03-29 11:40:44 +03:00
|
|
|
/* Apps - Slack Test Notification --------------------------------------------------------- */
|
|
|
|
|
|
|
|
this.post('/slack/test', function () {
|
|
|
|
return {};
|
|
|
|
});
|
|
|
|
|
Timezones: Always use the timezone of blog setting
closes TryGhost/Ghost#6406
follow-up PR of #2
- adds a `timeZone` Service to provide the offset (=timezone reg. moment-timezone) of the users blog settings
- `gh-datetime-input` will read the offset of the timezone now and adjust the `publishedAt` date with it. This is the date which will be shown in the PSM 'Publish Date' field. When the user writes a new date/time, the offset is considered and will be deducted again before saving it to the model. This way, we always work with a UTC publish date except for this input field.
- gets `availableTimezones` from `configuration/timezones` API endpoint
- adds a `moment-utc` transform on all date attr (`createdAt`, `updatedAt`, `publishedAt`, `unsubscribedAt` and `lastLogin`) to only work with UTC times on serverside
- when switching the timezone in the select box, the user will be shown the local time of the selected timezone
- `createdAt`-property in `gh-user-invited` returns now `moment(createdAt).fromNow()` as `createdAt` is a moment date already
- added clock service to show actual time ticking below select box
- default timezone is '(GMT) Greenwich Mean Time : Dublin, Edinburgh, London'
- if no timezone is saved in the settings yet, the default value will be used
- shows the local time in 'Publish Date' in PSM by default, until user overwrites it
- adds dependency `moment-timezone 0.5.4` to `bower.json`
---------
**Tests:**
- sets except for clock service in test env
- adds fixtures to mirage
- adds `service.ajax` and `service:ghostPaths` to navigation-test.js
- adds unit test for `gh-format-timeago` helper
- updates acceptance test `general-setting`
- adds acceptance test for `editor`
- adds integration tests for `services/config` and `services/time-zone`
---------
**Todos:**
- [ ] Integration tests: ~~`services/config`~~, ~~`services/time-zone`~~, `components/gh-datetime-input`
- [x] Acceptance test: `editor`
- [ ] Unit tests: `utils/date-formatting`
- [ ] write issue for renaming date properties (e. g. `createdAt` to `createdAtUTC`) and translate those for server side with serializers
2016-02-02 10:04:40 +03:00
|
|
|
/* Configuration -------------------------------------------------------- */
|
|
|
|
|
|
|
|
this.get('/configuration/timezones/', function (db) {
|
|
|
|
return {
|
|
|
|
configuration: [{
|
|
|
|
timezones: db.timezones
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2016-08-17 18:14:33 +03:00
|
|
|
/* External sites ------------------------------------------------------- */
|
2015-12-07 00:24:06 +03:00
|
|
|
|
2016-08-17 18:14:33 +03:00
|
|
|
let downloadCount = 0;
|
|
|
|
this.get('https://count.ghost.org/', function () {
|
|
|
|
downloadCount++;
|
2015-12-07 00:24:06 +03:00
|
|
|
return {
|
2016-08-17 18:14:33 +03:00
|
|
|
count: downloadCount
|
2015-12-07 00:24:06 +03:00
|
|
|
};
|
|
|
|
});
|
2016-03-03 11:52:27 +03:00
|
|
|
|
2016-04-12 14:34:40 +03:00
|
|
|
this.get('http://www.gravatar.com/avatar/:md5', function () {
|
|
|
|
return '';
|
|
|
|
}, 200);
|
2015-10-13 16:52:41 +03:00
|
|
|
}
|