Skip to content

Commit 85bb524

Browse files
committed
Merge pull request #50 from ember-cli-deploy/add-fetch-initial-revisions
add fetchInitialRevisions
2 parents d8d66be + db146a8 commit 85bb524

File tree

2 files changed

+68
-7
lines changed

2 files changed

+68
-7
lines changed

index.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,29 @@ module.exports = {
128128
}
129129
},
130130

131-
fetchRevisions: function(context) {
131+
fetchInitialRevisions: function(/* context */) {
132+
var redisDeployClient = this.readConfig('redisDeployClient');
133+
var keyPrefix = this.readConfig('keyPrefix');
134+
this.log('Listing initial revisions for key: `' + keyPrefix + '`', { verbose: true });
135+
return Promise.resolve(redisDeployClient.fetchRevisions(keyPrefix))
136+
.then(function(revisions) {
137+
return {
138+
initialRevisions: revisions
139+
};
140+
})
141+
.catch(this._errorMessage.bind(this));
142+
},
143+
144+
fetchRevisions: function(/* context */) {
132145
var redisDeployClient = this.readConfig('redisDeployClient');
133146
var keyPrefix = this.readConfig('keyPrefix');
134147

135148
this.log('Listing revisions for key: `' + keyPrefix + '`');
136149
return Promise.resolve(redisDeployClient.fetchRevisions(keyPrefix))
137-
.then(function(revisions){
138-
return { revisions: revisions };
150+
.then(function(revisions) {
151+
return {
152+
revisions: revisions
153+
};
139154
})
140155
.catch(this._errorMessage.bind(this));
141156
},

tests/unit/index-nodetest.js

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ describe('redis plugin', function() {
575575
});
576576
});
577577

578-
describe('fetchRevisions hook', function() {
579-
it('fills the revisions variable on context', function() {
578+
describe('fetchInitialRevisions hook', function() {
579+
it('fills the initialRevisions variable on context', function() {
580580
var plugin;
581581
var context;
582582

@@ -609,15 +609,61 @@ describe('redis plugin', function() {
609609
plugin.beforeHook(context);
610610
plugin.configure(context);
611611

612-
return assert.isFulfilled(plugin.fetchRevisions(context))
612+
return assert.isFulfilled(plugin.fetchInitialRevisions(context))
613613
.then(function(result) {
614614
assert.deepEqual(result, {
615-
revisions: [{
615+
initialRevisions: [{
616616
"active": false,
617617
"revision": "a"
618618
}]
619619
});
620620
});
621621
});
622622
});
623+
624+
describe('fetchRevisions hook', function() {
625+
it('fills the revisions variable on context', function() {
626+
var plugin;
627+
var context;
628+
629+
plugin = subject.createDeployPlugin({
630+
name: 'redis'
631+
});
632+
633+
context = {
634+
ui: mockUi,
635+
project: stubProject,
636+
config: {
637+
redis: {
638+
keyPrefix: 'test-prefix',
639+
filePattern: 'index.html',
640+
distDir: 'tests',
641+
revisionKey: '123abc',
642+
redisDeployClient: function(context) {
643+
return {
644+
fetchRevisions: function(keyPrefix, revisionKey) {
645+
return Promise.resolve([{
646+
revision: 'a',
647+
active: false
648+
}]);
649+
}
650+
};
651+
}
652+
}
653+
}
654+
};
655+
plugin.beforeHook(context);
656+
plugin.configure(context);
657+
658+
return assert.isFulfilled(plugin.fetchRevisions(context))
659+
.then(function(result) {
660+
assert.deepEqual(result, {
661+
revisions: [{
662+
"active": false,
663+
"revision": "a"
664+
}]
665+
});
666+
});
667+
});
668+
});
623669
});

0 commit comments

Comments
 (0)