From b0bb2adf69528582fba274308cff4afa7f1d6bc7 Mon Sep 17 00:00:00 2001 From: ferhat elmas Date: Tue, 17 Dec 2019 17:42:01 +0100 Subject: [PATCH] Fix lookup type assertion for reaction pagination --- src/lib/reaction.js | 5 ++++- test/integration/cloud/reaction.js | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib/reaction.js b/src/lib/reaction.js index 769894f3..fedebf17 100644 --- a/src/lib/reaction.js +++ b/src/lib/reaction.js @@ -183,7 +183,10 @@ StreamReaction.prototype = { qs.limit = 10; } - if ((user_id ? 1 : 0 + activity_id ? 1 : 0 + reaction_id ? 1 : 0) != 1) { + if ( + (user_id ? 1 : 0) + (activity_id ? 1 : 0) + (reaction_id ? 1 : 0) != + 1 + ) { throw new errors.SiteError( 'Must provide exactly one value for one of these params: user_id, activity_id, reaction_id', ); diff --git a/test/integration/cloud/reaction.js b/test/integration/cloud/reaction.js index 0509011e..3891669a 100644 --- a/test/integration/cloud/reaction.js +++ b/test/integration/cloud/reaction.js @@ -126,6 +126,16 @@ describe('Reaction pagination', () => { describe('Paginate the whole thing', () => { let resp; + ctx.test('errors with multiple lookup types', async () => { + let conditions = { + activity_id: eatActivity.id, + user_id: ctx.alice.userId, + }; + expect(ctx.alice.reactions.filter) + .withArgs(conditions) + .to.throwError(); + }); + ctx.test('reactions should be enriched when filtering', async () => { let conditions = { activity_id: eatActivity.id,