mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
recieve togglename to archive or revive via path
This commit is contained in:
parent
d6bdc578c9
commit
baf2c62f25
@ -77,16 +77,16 @@ class FeatureToggleStore {
|
||||
.catch(err => logger.error('Could not update feature, error was: ', err));
|
||||
}
|
||||
|
||||
_archiveFeature (data) {
|
||||
return this.db('features')
|
||||
.where({ name: data.name })
|
||||
_archiveFeature ({ name }) {
|
||||
return this.db(TABLE)
|
||||
.where({ name })
|
||||
.update({ archived: 1 })
|
||||
.catch(err => logger.error('Could not archive feature, error was: ', err));
|
||||
}
|
||||
|
||||
_reviveFeature (data) {
|
||||
return this.db('features')
|
||||
.where({ name: data.name })
|
||||
_reviveFeature ({ name }) {
|
||||
return this.db(TABLE)
|
||||
.where({ name })
|
||||
.update({ archived: 0, enabled: 0 })
|
||||
.catch(err => logger.error('Could not archive feature, error was: ', err));
|
||||
}
|
||||
|
@ -29,14 +29,14 @@ module.exports = function (app, config) {
|
||||
});
|
||||
});
|
||||
|
||||
app.post('/archive/revive', (req, res) => {
|
||||
req.checkBody('name', 'Name is required').notEmpty();
|
||||
app.post('/archive/revive/:name', (req, res) => {
|
||||
req.checkParams('name', 'Name is required').notEmpty();
|
||||
|
||||
validateRequest(req)
|
||||
.then(() => eventStore.store({
|
||||
type: FEATURE_REVIVED,
|
||||
createdBy: req.connection.remoteAddress,
|
||||
data: req.body,
|
||||
data: { name: req.params.name },
|
||||
}))
|
||||
.then(() => res.status(200).end())
|
||||
.catch(error => handleErrors(req, res, error));
|
||||
|
@ -23,8 +23,7 @@ test.serial('returns three archived toggles', async t => {
|
||||
test.serial('revives a feature by name', async t => {
|
||||
const { request, destroy } = await setupApp('archive_serial');
|
||||
return request
|
||||
.post('/api/archive/revive')
|
||||
.send({ name: 'featureArchivedX' })
|
||||
.post('/api/archive/revive/featureArchivedX')
|
||||
.set('Content-Type', 'application/json')
|
||||
.expect(200)
|
||||
.then(destroy);
|
||||
@ -33,8 +32,7 @@ test.serial('revives a feature by name', async t => {
|
||||
test.serial('must set name when reviving toggle', async t => {
|
||||
const { request, destroy } = await setupApp('archive_serial');
|
||||
return request
|
||||
.post('/api/archive/revive')
|
||||
.send({ name: '' })
|
||||
.expect(400)
|
||||
.post('/api/archive/revive/')
|
||||
.expect(404)
|
||||
.then(destroy);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user