mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-23 01:27:14 +02:00
Fixing settings setting tests #683
This commit is contained in:
parent
8fc0512998
commit
cb8553896f
@ -1,4 +1,5 @@
|
||||
/**
|
||||
* Keeps the environment context
|
||||
* Only use it in the Config constructor
|
||||
*/
|
||||
export const ServerEnvironment: { sendMailAvailable?: boolean } = {};
|
||||
|
@ -7,6 +7,7 @@ import {IConfigClass} from 'typeconfig/common';
|
||||
import {PasswordHelper} from '../../../backend/model/PasswordHelper';
|
||||
import {TAGS} from '../public/ClientConfig';
|
||||
import {ServerEnvironment} from '../../../backend/Environment';
|
||||
import {EmailMessagingType} from './MessagingConfig';
|
||||
|
||||
declare const process: any;
|
||||
|
||||
@ -82,6 +83,9 @@ export class PrivateConfigClass extends ServerConfig {
|
||||
this.Environment.isDocker = !!process.env.PI_DOCKER;
|
||||
if (typeof ServerEnvironment.sendMailAvailable !== 'undefined') {
|
||||
this.Environment.sendMailAvailable = ServerEnvironment.sendMailAvailable;
|
||||
if(!this.Environment.sendMailAvailable){ //onNewValue is not yet available as a callback
|
||||
this.Messaging.Email.type = EmailMessagingType.SMTP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,8 @@ import {SettingsMWs} from '../../../../../src/backend/middlewares/admin/Settings
|
||||
import {ServerUserConfig} from '../../../../../src/common/config/private/PrivateConfig';
|
||||
import {Config} from '../../../../../src/common/config/private/Config';
|
||||
import {UserRoles} from '../../../../../src/common/entities/UserDTO';
|
||||
import {ConfigClassBuilder} from '../../../../../node_modules/typeconfig/node';
|
||||
import {ServerEnvironment} from '../../../../../src/backend/Environment';
|
||||
|
||||
|
||||
declare const describe: any;
|
||||
@ -19,6 +21,8 @@ describe('Settings middleware', () => {
|
||||
});
|
||||
|
||||
it('should save empty enforced users settings', (done: (err?: any) => void) => {
|
||||
|
||||
ServerEnvironment.sendMailAvailable = false;
|
||||
const req: any = {
|
||||
session: {},
|
||||
sessionOptions: {},
|
||||
@ -26,12 +30,13 @@ describe('Settings middleware', () => {
|
||||
params: {},
|
||||
body: {
|
||||
settingsPath: 'Users',
|
||||
settings: new ServerUserConfig()
|
||||
settings: ConfigClassBuilder.attachPrivateInterface(new ServerUserConfig()).toJSON()
|
||||
}
|
||||
};
|
||||
req.body.settings.enforcedUsers = [];
|
||||
const next: any = (err: ErrorDTO) => {
|
||||
try {
|
||||
expect(err).to.be.undefined;
|
||||
expect(Config.Users.enforcedUsers.length).to.be.equal(0);
|
||||
done();
|
||||
} catch (err) {
|
||||
|
Loading…
Reference in New Issue
Block a user