mirror of
https://github.com/strapi/strapi.git
synced 2025-11-07 21:58:23 +00:00
fix permission + simplify test
This commit is contained in:
parent
35a13433f0
commit
c84ad063bb
@ -29,7 +29,7 @@ module.exports = {
|
|||||||
const entityManager = getService('entity-manager');
|
const entityManager = getService('entity-manager');
|
||||||
const permissionChecker = getService('permission-checker').create({
|
const permissionChecker = getService('permission-checker').create({
|
||||||
userAbility,
|
userAbility,
|
||||||
model: sourceModel,
|
model,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (permissionChecker.cannot.read()) {
|
if (permissionChecker.cannot.read()) {
|
||||||
|
|||||||
@ -61,6 +61,15 @@ const shopModel = {
|
|||||||
pluralName: 'shops',
|
pluralName: 'shops',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const createEntry = async (uid, data) => {
|
||||||
|
const { body } = await rq({
|
||||||
|
method: 'POST',
|
||||||
|
url: `/content-manager/collection-types/${uid}`,
|
||||||
|
body: data,
|
||||||
|
});
|
||||||
|
return body;
|
||||||
|
};
|
||||||
|
|
||||||
describe('Relations', () => {
|
describe('Relations', () => {
|
||||||
const builder = createTestBuilder();
|
const builder = createTestBuilder();
|
||||||
|
|
||||||
@ -74,28 +83,16 @@ describe('Relations', () => {
|
|||||||
strapi = await createStrapiInstance();
|
strapi = await createStrapiInstance();
|
||||||
rq = await createAuthRequest({ strapi });
|
rq = await createAuthRequest({ strapi });
|
||||||
|
|
||||||
const { body: createdProduct1 } = await rq({
|
const createdProduct1 = await createEntry('api::product.product', { name: 'Skate' });
|
||||||
method: 'POST',
|
const createdProduct2 = await createEntry('api::product.product', { name: 'Candle' });
|
||||||
url: '/content-manager/collection-types/api::product.product',
|
|
||||||
body: { name: 'Skate' },
|
|
||||||
});
|
|
||||||
const { body: createdProduct2 } = await rq({
|
|
||||||
method: 'POST',
|
|
||||||
url: '/content-manager/collection-types/api::product.product',
|
|
||||||
body: { name: 'Candle' },
|
|
||||||
});
|
|
||||||
|
|
||||||
data.products.push(createdProduct1);
|
data.products.push(createdProduct1);
|
||||||
data.products.push(createdProduct2);
|
data.products.push(createdProduct2);
|
||||||
|
|
||||||
const { body: createdShop } = await rq({
|
const createdShop = await createEntry('api::shop.shop', {
|
||||||
method: 'POST',
|
|
||||||
url: '/content-manager/collection-types/api::shop.shop',
|
|
||||||
body: {
|
|
||||||
name: 'Cazotte Shop',
|
name: 'Cazotte Shop',
|
||||||
products: [createdProduct1.id],
|
products: [createdProduct1.id],
|
||||||
myCompo: { compoProducts: [createdProduct2.id] },
|
myCompo: { compoProducts: [createdProduct2.id] },
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
data.shops.push(createdShop);
|
data.shops.push(createdShop);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user