Skip to content

Commit 8cf7081

Browse files
committed
Fix: Activation of unknown key sets current rev
Fixes #14
1 parent 96df240 commit 8cf7081

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

lib/redis.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,18 @@ module.exports = CoreObject.extend({
5151
var uploadKey = this._currentKey();
5252
var that = this;
5353

54-
return new RSVP.Promise(function(resolve, reject) {
55-
that._list()
56-
.then(function(uploads) {
57-
return uploads.indexOf(revisionKey) > -1 ? resolve() : reject();
58-
})
59-
.then(function() {
60-
return that.client.set(uploadKey, revisionKey);
61-
})
62-
.then(resolve);
63-
})
64-
.then(this._activationSuccessfulMessage)
65-
.then(this._printSuccessMessage.bind(this))
66-
.catch(function() {
67-
return this._printErrorMessage(this._revisionNotFoundMessage());
68-
}.bind(this));
54+
return this._list()
55+
.then(function(uploads) {
56+
return uploads.indexOf(revisionKey) > -1 ? RSVP.resolve() : RSVP.reject();
57+
})
58+
.then(function() {
59+
return that.client.set(uploadKey, revisionKey);
60+
})
61+
.then(this._activationSuccessfulMessage)
62+
.then(this._printSuccessMessage.bind(this))
63+
.catch(function() {
64+
return this._printErrorMessage(this._revisionNotFoundMessage());
65+
}.bind(this));
6966
},
7067

7168
_list: function() {

node_tests/unit/lib/redis-test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,23 @@ describe('RedisAdapter', function() {
262262

263263
return expect(activation).to.be.rejectedWith(SilentError, /Error!/);
264264
});
265+
266+
it('does not set the current revision when key is not in manifest', function() {
267+
activation = uploadsDone
268+
.then(function() {
269+
return redisAdapter.activate(revisionsList[0]);
270+
})
271+
.then(function() {
272+
return redisAdapter.activate('does-not-exist');
273+
});
274+
return expect(activation).to.be.rejected
275+
.then(function() {
276+
return redisAdapter._current();
277+
})
278+
.then(function(currentRevision) {
279+
return expect(currentRevision).to.eql(revisionsList[0]);
280+
});
281+
});
265282
});
266283

267284
describe('#_current', function() {

0 commit comments

Comments
 (0)