Commit 2b4b0506 authored by Robert Knight's avatar Robert Knight

Remove "community_groups" feature flag checks from groups service

parent 2ca9f92c
......@@ -29,8 +29,7 @@ function groups(
serviceUrl,
session,
settings,
auth,
features
auth
) {
const svc = serviceConfig(settings);
const authority = svc ? svc.authority : null;
......@@ -299,25 +298,8 @@ function groups(
return groups;
}
const sortGroups = memoize(groups => {
// Sort in the following order: scoped, public, private.
// This is for maintaining the order of the old groups menu so when
// the old groups menu is removed this can be removed.
const worldGroups = groups.filter(g => g.id === '__world__');
const nonWorldScopedGroups = groups.filter(
g => g.id !== '__world__' && ['open', 'restricted'].includes(g.type)
);
const remainingGroups = groups.filter(
g => !worldGroups.includes(g) && !nonWorldScopedGroups.includes(g)
);
return nonWorldScopedGroups.concat(worldGroups).concat(remainingGroups);
});
function all() {
if (features.flagEnabled('community_groups')) {
return store.allGroups();
}
return sortGroups(store.getInScopeGroups());
return store.allGroups();
}
// Return the full object for the group with the given id.
......
......@@ -41,7 +41,6 @@ const dummyGroups = [
describe('groups', function() {
let fakeAuth;
let fakeFeatures;
let fakeStore;
let fakeIsSidebar;
let fakeSession;
......@@ -55,9 +54,6 @@ describe('groups', function() {
fakeAuth = {
tokenGetter: sinon.stub().returns('1234'),
};
fakeFeatures = {
flagEnabled: sinon.stub().returns(false),
};
fakeStore = fakeReduxStore(
{
......@@ -146,42 +142,17 @@ describe('groups', function() {
fakeServiceUrl,
fakeSession,
fakeSettings,
fakeAuth,
fakeFeatures
fakeAuth
);
}
describe('#all', function() {
it('returns all groups from store.allGroups when community-groups feature flag is enabled', () => {
it('returns all groups from store.allGroups', () => {
const svc = service();
fakeStore.allGroups = sinon.stub().returns(dummyGroups);
fakeFeatures.flagEnabled.withArgs('community_groups').returns(true);
assert.deepEqual(svc.all(), dummyGroups);
assert.called(fakeStore.allGroups);
});
it('returns all groups from store.getInScopeGroups when community-groups feature flag is disabled', () => {
const svc = service();
fakeStore.getInScopeGroups = sinon.stub().returns(dummyGroups);
assert.deepEqual(svc.all(), dummyGroups);
assert.called(fakeStore.getInScopeGroups);
});
[[0, 1, 2, 3], [2, 0, 1, 3], [0, 3, 1, 2]].forEach(groupInputOrder => {
it('sorts the groups in the following order: scoped, public, private maintaining order within each category.', () => {
const groups = [
{ id: 0, type: 'open' },
{ id: 1, type: 'restricted' },
{ id: '__world__', type: 'open' },
{ id: 3, type: 'private' },
];
const svc = service();
fakeStore.getInScopeGroups = sinon
.stub()
.returns(groupInputOrder.map(id => groups[id]));
assert.deepEqual(svc.all(), groups);
});
});
});
describe('#load', function() {
......
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