mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +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:
commit
669c860c8d
@ -47,7 +47,7 @@ class FeatureToggleStore {
|
||||
return this.db
|
||||
.first(FEATURE_COLUMNS)
|
||||
.from(TABLE)
|
||||
.where({ name })
|
||||
.where({ name, archived: 0 })
|
||||
.then(this.rowToFeature);
|
||||
}
|
||||
|
||||
@ -103,10 +103,10 @@ class FeatureToggleStore {
|
||||
_archiveFeature({ name }) {
|
||||
return this.db(TABLE)
|
||||
.where({ name })
|
||||
.update({ archived: 1 })
|
||||
.catch(err =>
|
||||
logger.error('Could not archive feature, error was: ', err)
|
||||
);
|
||||
.update({ archived: 1, enabled: 0 })
|
||||
.catch(err => {
|
||||
logger.error('Could not archive feature, error was: ', err);
|
||||
});
|
||||
}
|
||||
|
||||
_reviveFeature({ name }) {
|
||||
|
@ -31,6 +31,30 @@ test.serial('revives a feature by name', async t => {
|
||||
.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 => {
|
||||
t.plan(0);
|
||||
const { request, destroy } = await setupApp('archive_serial');
|
||||
|
Loading…
Reference in New Issue
Block a user