Skip to content

Commit

Permalink
WIP Added filterIncludesByEnv implementation and uncomment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KalinichenkoP committed Jul 15, 2021
1 parent b7610aa commit a70343b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/services/relationships.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class RelationshipsService {
logger.info(`Getting resources of ids: ${ids}`);
delete query.ids;
delete query.usersRole;
const filterIncludesByEnv = query.filterIncludesByEnv ? query.filterIncludesByEnv : false;
if(!filterIncludesByEnv) {
delete query.env
}
let resources = includes.map(async (include) => {
const obj = {};
if (INCLUDES.indexOf(include) >= 0) {
Expand Down Expand Up @@ -83,7 +87,7 @@ class RelationshipsService {
if (resources[include]) {
const { data } = resources[include];
const result = {};
if (data.length > 0) {
if (data && data.length > 0) {
data.forEach((el) => {
if (include === 'vocabulary') { // particular case of vocabulary. it changes the matching attr
if (Object.keys(result).indexOf(el.attributes.resource.id) < 0) {
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/dataset-get-includes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ describe('Get datasets with includes', () => {

describe('Environments', () => {

it.skip('Get datasets with includes and search, with no filterIncludesByEnv filter and no env value, should load included data without filtering it by env', async () => {
it('Get datasets with includes and search, with no filterIncludesByEnv filter and no env value, should load included data without filtering it by env', async () => {
const fakeDatasetOne = await new Dataset(createDataset('cartodb')).save();

nock(process.env.GATEWAY_URL)
Expand Down Expand Up @@ -450,7 +450,7 @@ describe('Get datasets with includes', () => {
response.body.data[0].should.deep.equal(datasetGetIncludeAllAnonymous(fakeDatasetOne));
});

it.skip('Get datasets with includes and search, with no filterIncludesByEnv filter and custom env, should load included data without filtering it by env', async () => {
it('Get datasets with includes and search, with no filterIncludesByEnv filter and custom env, should load included data without filtering it by env', async () => {
const fakeDatasetOne = await new Dataset(createDataset('cartodb', { env: 'custom' })).save();

nock(process.env.GATEWAY_URL)
Expand Down Expand Up @@ -528,7 +528,7 @@ describe('Get datasets with includes', () => {
response.body.data[0].should.deep.equal(datasetGetIncludeAllAnonymous(fakeDatasetOne));
});

it.skip('Get datasets with includes and search, with filterIncludesByEnv set to true and custom env, should load included data filtered by env', async () => {
it('Get datasets with includes and search, with filterIncludesByEnv set to true and custom env, should load included data filtered by env', async () => {
const fakeDatasetOne = await new Dataset(createDataset('cartodb')).save();

nock(process.env.GATEWAY_URL)
Expand Down

0 comments on commit a70343b

Please sign in to comment.