Skip to content

Commit

Permalink
Fixed toObject on new lean implementation. (#7094)
Browse files Browse the repository at this point in the history
* Fixed toObject on new lean implementation.

* Upped version
  • Loading branch information
RafaPolit authored Aug 2, 2024
1 parent ec919cc commit a0539c5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
39 changes: 39 additions & 0 deletions app/api/tenants/specs/tenantsContext.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { DB } from 'api/odm/DB';
import { Db } from 'mongodb';
import testingDB from 'api/utils/testing_db';
import { testingEnvironment } from 'api/utils/testingEnvironment';
import { config } from 'api/config';
import { tenants } from '../tenantContext';
import { tenantsModel } from '../tenantsModel';

describe('tenantsContext', () => {
describe('add', () => {
Expand All @@ -14,4 +19,38 @@ describe('tenantsContext', () => {
}, 'test-tenant');
});
});

describe('updateTenants', () => {
let db: Db;

beforeAll(async () => {
await testingDB.connect();
testingEnvironment.setRequestId();
db = DB.connectionForDB(config.SHARED_DB).db;

await db.collection('tenants').deleteMany({});
await db.collection('tenants').insertMany([
{
name: 'tenant one',
dbName: 'tenant_one',
},
{
name: 'tenant two',
dbName: 'tenant_two',
},
]);
});

afterAll(async () => {
await db.collection('tenants').deleteMany({});
await testingEnvironment.tearDown();
});

it('should udpate tenants with DB data', async () => {
await tenants.updateTenants(await tenantsModel());

expect(tenants.tenants['tenant one'].dbName).toBe('tenant_one');
expect(tenants.tenants['tenant two'].dbName).toBe('tenant_two');
});
});
});
2 changes: 1 addition & 1 deletion app/api/tenants/tenantContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Tenants {
const tenants = await model.get();

tenants.forEach((tenant: TenantDocument) => {
this.add(tenant.toObject());
this.add(tenant);
});
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uwazi",
"version": "1.177.2",
"version": "1.177.3",
"description": "Uwazi is a free, open-source solution for organising, analysing and publishing your documents.",
"keywords": [
"react"
Expand Down

0 comments on commit a0539c5

Please sign in to comment.