mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +03:00
07cb542b97
fixes https://github.com/TryGhost/Team/issues/1946 Problem: - When running the admin tests in a timezone that is later than UTC, the tests failed. Causes: - Some tests needed some adjustements - The DateTimePicker did not always use the correct timezone. - Test models createdAt times sometimes depended on the timezone of the test runner Solution: - All the input DateTimePicker gets should be processed in the blog's timezone. - Make sure that all communication (properties, setters, minDate...) with `PowerDatepicker` happens in the local timezone. When setting, convert that date to the blog timezone and use that as the real value.
34 lines
921 B
JavaScript
34 lines
921 B
JavaScript
import faker from 'faker';
|
|
import moment from 'moment-timezone';
|
|
import {Factory, trait} from 'miragejs';
|
|
|
|
let randomDate = function randomDate(start = moment().subtract(30, 'days').toDate(), end = new Date()) {
|
|
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
|
|
};
|
|
|
|
export default Factory.extend({
|
|
name() { return `${faker.name.firstName()} ${faker.name.lastName()}`; },
|
|
email: faker.internet.email,
|
|
status: 'free',
|
|
createdAt() { return moment.utc(randomDate()).format('YYYY-MM-DD HH:mm:ss'); },
|
|
|
|
free: trait({
|
|
status: 'free'
|
|
}),
|
|
|
|
paid: trait({
|
|
status: 'paid'
|
|
}),
|
|
|
|
comped: trait({
|
|
status: 'comped'
|
|
}),
|
|
|
|
afterCreate(member, server) {
|
|
const newslettersToSignup = server.schema.newsletters.where({subscribeOnSignup: true});
|
|
|
|
member.newsletters = newslettersToSignup;
|
|
member.save();
|
|
}
|
|
});
|