Skip to content

Commit caef96c

Browse files
committed
Merge pull request #51 from LevelbossMike/more-hook-tests
Add tests for untested hooks
2 parents 02a535b + 3be3056 commit caef96c

File tree

8 files changed

+209
-118
lines changed

8 files changed

+209
-118
lines changed

.jshintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/dist
2+
/tmp
3+
/node_modules
4+
/bower_components
5+
config

index.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* jshint node: true */
22
'use strict';
33
var path = require('path');
4-
var Promise = require('ember-cli/lib/ext/promise');
54
var DeployPluginBase = require('ember-cli-deploy-plugin');
65
var S3 = require('./lib/s3');
76

@@ -11,6 +10,7 @@ module.exports = {
1110
createDeployPlugin: function(options) {
1211
var DeployPlugin = DeployPluginBase.extend({
1312
name: options.name,
13+
S3: options.S3 || S3,
1414

1515
defaultConfig: {
1616
filePattern: 'index.html',
@@ -26,9 +26,6 @@ module.exports = {
2626
s3Client: function(context) {
2727
return context.s3Client; // if you want to provide your own S3 client to be used instead of one from aws-sdk
2828
},
29-
s3DeployClient: function(/* context */) {
30-
return new S3({ plugin: this });
31-
},
3229
gzippedFiles: function(context) {
3330
return context.gzippedFiles || [];
3431
},
@@ -37,7 +34,7 @@ module.exports = {
3734

3835
requiredConfig: ['bucket', 'region'],
3936

40-
upload: function(context) {
37+
upload: function(/* context */) {
4138
var bucket = this.readConfig('bucket');
4239
var prefix = this.readConfig('prefix');
4340
var acl = this.readConfig('acl');
@@ -61,11 +58,11 @@ module.exports = {
6158

6259
this.log('preparing to upload revision to S3 bucket `' + bucket + '`', { verbose: true });
6360

64-
var s3 = this.readConfig('s3DeployClient');
61+
var s3 = new this.S3({ plugin: this });
6562
return s3.upload(options);
6663
},
6764

68-
activate: function(context) {
65+
activate: function(/* context */) {
6966
var bucket = this.readConfig('bucket');
7067
var prefix = this.readConfig('prefix');
7168
var acl = this.readConfig('acl');
@@ -82,7 +79,7 @@ module.exports = {
8279

8380
this.log('preparing to activate `' + revisionKey + '`', { verbose: true });
8481

85-
var s3 = this.readConfig('s3DeployClient');
82+
var s3 = new this.S3({ plugin: this });
8683
return s3.activate(options);
8784
},
8885

@@ -115,7 +112,7 @@ module.exports = {
115112
filePattern: filePattern,
116113
};
117114

118-
var s3 = this.readConfig('s3DeployClient');
115+
var s3 = new this.S3({ plugin: this });
119116
return s3.fetchRevisions(options);
120117
}
121118
});

lib/s3.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/* jshint node: true */
2+
'use strict';
3+
14
var AWS = require('aws-sdk');
25
var CoreObject = require('core-object');
36
var Promise = require('ember-cli/lib/ext/promise');
@@ -52,7 +55,7 @@ module.exports = CoreObject.extend({
5255
ACL: acl,
5356
ContentType: mime.lookup(options.filePath) || 'text/html',
5457
CacheControl: 'max-age=0, no-cache'
55-
}
58+
};
5659

5760
if (isGzipped) {
5861
params.ContentEncoding = 'gzip';
@@ -62,7 +65,7 @@ module.exports = CoreObject.extend({
6265
.then(function(revisions) {
6366
var found = revisions.map(function(element) { return element.revision; }).indexOf(options.revisionKey);
6467
if (found >= 0 && !allowOverwrite) {
65-
return Promise.reject("REVISION ALREADY UPLOADED! (set `allowOverwrite: true` if you want to support overwriting revisions)")
68+
return Promise.reject("REVISION ALREADY UPLOADED! (set `allowOverwrite: true` if you want to support overwriting revisions)");
6669
}
6770
return Promise.resolve();
6871
})
@@ -80,7 +83,7 @@ module.exports = CoreObject.extend({
8083
var client = this._client;
8184
var bucket = options.bucket;
8285
var acl = options.acl;
83-
var prefix = options.prefix
86+
var prefix = options.prefix;
8487
var filePattern = options.filePattern;
8588
var key = filePattern + ":" + options.revisionKey;
8689

@@ -101,7 +104,7 @@ module.exports = CoreObject.extend({
101104
if (found >= 0) {
102105
return copyObject(params).then(function() {
103106
plugin.log('✔ ' + revisionKey + " => " + indexKey);
104-
})
107+
});
105108
} else {
106109
return Promise.reject("REVISION NOT FOUND!"); // see how we should handle a pipeline failure
107110
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@
3838
"ember-disable-proxy-controllers": "^1.0.0",
3939
"ember-export-application-global": "^1.0.3",
4040
"ember-try": "0.0.6",
41+
"github": "^0.2.4",
4142
"glob": "^5.0.15",
4243
"mocha": "^2.3.3",
43-
"github": "^0.2.4",
44+
"mocha-jshint": "^2.3.1",
4445
"multiline": "^1.0.2"
4546
},
4647
"keywords": [
@@ -57,4 +58,4 @@
5758
"ember-addon": {
5859
"configPath": "tests/dummy/config"
5960
}
60-
}
61+
}

tests/.jshintrc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@
2121
"andThen",
2222
"currentURL",
2323
"currentPath",
24-
"currentRouteName"
24+
"currentRouteName",
25+
"describe",
26+
"before",
27+
"beforeEach",
28+
"afterEach",
29+
"it"
2530
],
26-
"node": false,
31+
"node": true,
2732
"browser": false,
2833
"boss": true,
2934
"curly": true,

0 commit comments

Comments
 (0)