Commit 3ebc9ef1 authored by Andrew Fontaine's avatar Andrew Fontaine

Ensure When userWithId Is Picked User IDs are Sent

Before, userWithId would send a strategy with an empty set of parameters
as well as a strategy with the correct set of parameters.

This ensures that the primary strategy is created correctly, as well as
ensuring supplementary user IDs are added if needed.

It also removes some old code from when the user IDs were an Array.
parent 297cf2c9
......@@ -59,18 +59,18 @@ export const mapToScopesViewModel = scopesFromRails =>
*/
export const mapFromScopesViewModel = params => {
const scopes = (params.scopes || []).map(s => {
const percentParameters = {};
const parameters = {};
if (s.rolloutStrategy === ROLLOUT_STRATEGY_PERCENT_ROLLOUT) {
percentParameters.groupId = PERCENT_ROLLOUT_GROUP_ID;
percentParameters.percentage = s.rolloutPercentage;
parameters.groupId = PERCENT_ROLLOUT_GROUP_ID;
parameters.percentage = s.rolloutPercentage;
} else if (s.rolloutStrategy === ROLLOUT_STRATEGY_USER_ID) {
parameters.userIds = (s.rolloutUserIds || '').replace(/, /g, ',');
}
const userIdParameters = {};
if (s.shouldIncludeUserIds || s.rolloutStrategy === ROLLOUT_STRATEGY_USER_ID) {
if (s.shouldIncludeUserIds && s.rolloutStrategy !== ROLLOUT_STRATEGY_USER_ID) {
userIdParameters.userIds = (s.rolloutUserIds || '').replace(/, /g, ',');
} else if (Array.isArray(s.rolloutUserIds) && s.rolloutUserIds.length > 0) {
userIdParameters.userIds = s.rolloutUserIds.join(',');
}
// Strip out any internal IDs
......@@ -79,7 +79,7 @@ export const mapFromScopesViewModel = params => {
const strategies = [
{
name: s.rolloutStrategy,
parameters: percentParameters,
parameters,
},
];
......
---
title: Ensure When userWithId Is Picked User IDs are Sent
merge_request: 22528
author:
type: fixed
......@@ -161,9 +161,10 @@ describe('feature flags helpers spec', () => {
canUpdate: true,
protected: true,
shouldBeDestroyed: true,
shouldIncludeUserIds: true,
rolloutStrategy: ROLLOUT_STRATEGY_PERCENT_ROLLOUT,
rolloutPercentage: '48',
rolloutUserIds: ['123', '234'],
rolloutUserIds: '123, 234',
},
],
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment