1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-01 00:08:27 +01:00

Merge pull request #241 from Unleash/archive-feature-fix

Auto disable archived toggles and do not serve archived toggle
This commit is contained in:
Sveinung Røsaker 2017-06-28 19:33:38 +02:00 committed by GitHub
commit 669c860c8d
2 changed files with 29 additions and 5 deletions

View File

@ -47,7 +47,7 @@ class FeatureToggleStore {
return this.db return this.db
.first(FEATURE_COLUMNS) .first(FEATURE_COLUMNS)
.from(TABLE) .from(TABLE)
.where({ name }) .where({ name, archived: 0 })
.then(this.rowToFeature); .then(this.rowToFeature);
} }
@ -103,10 +103,10 @@ class FeatureToggleStore {
_archiveFeature({ name }) { _archiveFeature({ name }) {
return this.db(TABLE) return this.db(TABLE)
.where({ name }) .where({ name })
.update({ archived: 1 }) .update({ archived: 1, enabled: 0 })
.catch(err => .catch(err => {
logger.error('Could not archive feature, error was: ', err) logger.error('Could not archive feature, error was: ', err);
); });
} }
_reviveFeature({ name }) { _reviveFeature({ name }) {

View File

@ -31,6 +31,30 @@ test.serial('revives a feature by name', async t => {
.then(destroy); .then(destroy);
}); });
test.serial(
'archived feature is not accessible via /features/:featureName',
async t => {
t.plan(0);
const { request, destroy } = await setupApp('archive_serial2');
await request
.get('/api/admin/features/featureX')
.set('Content-Type', 'application/json')
.expect(200);
await request
.delete('/api/admin/features/featureX')
.set('Content-Type', 'application/json')
.expect(200);
return request
.get('/api/admin/features/featureX')
.set('Content-Type', 'application/json')
.expect(404)
.then(destroy);
}
);
test.serial('must set name when reviving toggle', async t => { test.serial('must set name when reviving toggle', async t => {
t.plan(0); t.plan(0);
const { request, destroy } = await setupApp('archive_serial'); const { request, destroy } = await setupApp('archive_serial');