This repository has been archived by the owner on Jul 4, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ember-learn/setting-up
Setting up
Showing
6 changed files
with
124 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
language: node_js | ||
node_js: | ||
- "0.10" | ||
|
||
sudo: false | ||
|
||
cache: | ||
directories: | ||
- node_modules | ||
|
||
before_install: | ||
- "npm config set spin false" | ||
- "npm install -g npm@^2" | ||
|
||
install: | ||
- npm install | ||
|
||
script: | ||
- npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Created by dbaker on 5/2/16. | ||
*/ | ||
var firebase = require("firebase"); | ||
var firebaseHost = process.env.FIREBASE_APP || '"https://<app-name>.firebaseio.com/";'; | ||
|
||
module.exports = { | ||
addIssue: function(repo, issueId, payload) { | ||
var ref = this._setupFirebase(firebaseHost); | ||
//ref.authWithCustomToken(AUTH_TOKEN, function(error, authData) { | ||
|
||
repo = this._modifyRepoNameIfNeeded(repo); | ||
var path = 'issues/' + repo + '/' + issueId | ||
var issueRef = this._getStoreReference(ref, path); | ||
issueRef.set(payload, function(error) { | ||
if (error) { | ||
console.log('failures' + error); | ||
return false; | ||
} | ||
return true; | ||
}); | ||
|
||
return true; | ||
// return process.env['FIREBASE_SECRET']; | ||
}, | ||
|
||
_setupFirebase: function(host) { | ||
return new firebase(host); | ||
}, | ||
|
||
_modifyRepoNameIfNeeded: function(repo) { | ||
return repo.replace('.', ''); | ||
}, | ||
|
||
_getStoreReference: function(ref, path) { | ||
return ref.child(path); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
"sinon": "^1.17.3" | ||
}, | ||
"dependencies": { | ||
"firebase": "^2.4.2", | ||
"github-webhook-handler": "^0.5.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* jshint node: true */ | ||
/* jshint mocha: true */ | ||
'use strict'; | ||
|
||
var assert = require('assert'); | ||
var path = require('path'); | ||
var sinon = require('sinon'); | ||
|
||
var DataStore = require('../../lib/datastore-client'); | ||
|
||
describe('adding an issue works', function() { | ||
|
||
it('generates appropriate path for a normal repo name', function() { | ||
|
||
var clientStub = sinon.stub(DataStore, '_setupFirebase', fakeHost); | ||
var referenceStub = sinon.stub(DataStore, '_getStoreReference', fakeIssueRef); | ||
|
||
var result = DataStore.addIssue('ember-cli/ember-cli', 10, {name: 'fakeData'}); | ||
|
||
clientStub.restore(); | ||
referenceStub.restore(); | ||
sinon.assert.calledWith(referenceStub, 'host-name', 'issues/ember-cli/ember-cli/10'); | ||
|
||
assert.ok(result, 'issue not properly sent to client'); | ||
}); | ||
|
||
it('generates modified path if we have a period in the name', function() { | ||
|
||
var clientStub = sinon.stub(DataStore, '_setupFirebase', fakeHost); | ||
var referenceStub = sinon.stub(DataStore, '_getStoreReference', fakeIssueRef); | ||
|
||
var result = DataStore.addIssue('emberjs/ember.js', 10, {name: 'fakeData'}); | ||
|
||
clientStub.restore(); | ||
referenceStub.restore(); | ||
sinon.assert.calledWith(referenceStub, 'host-name', 'issues/emberjs/emberjs/10'); | ||
|
||
assert.ok(result, 'issue not properly sent to client'); | ||
}); | ||
}); | ||
|
||
function fakeHost() { | ||
return 'host-name'; | ||
} | ||
|
||
function fakeIssueRef() { | ||
return { | ||
set: sinon.stub().returns(true) | ||
} | ||
} |