-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(achievements): cutting edge (#171)
* Add cutting edge tests and achievement * Untrack yarn lock * Update README * Rename achievement to Cutting Edges because it sounds more dangerous
- Loading branch information
1 parent
2631e44
commit 046425b
Showing
5 changed files
with
98 additions
and
2 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 |
---|---|---|
|
@@ -10,4 +10,6 @@ monkeyDB.json | |
|
||
mochawesome-report/ | ||
|
||
privateConfig.json | ||
privateConfig.json | ||
package-lock.json | ||
yarn.lock |
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,26 @@ | ||
var _ = require('lodash'); | ||
|
||
var cuttingEdge = { | ||
name: 'Cutting Edges', | ||
check: function(pullRequest, shall) { | ||
if (pullRequest.merged) { | ||
const anyApprovals = _.some(pullRequest.reviews, function(review) { | ||
return review.state === 'APPROVED'; | ||
}); | ||
|
||
if (!anyApprovals) { | ||
var achieve = { | ||
avatar: 'images/achievements/cuttingEdges.achievement.jpg', | ||
name: 'Cutting Edges', | ||
short: 'Cutting corners? I also like to live dangerously', | ||
description: 'You\'ve merged a pull request without a reviewer confirming', | ||
relatedPullRequest: pullRequest.id | ||
}; | ||
|
||
shall.grant(pullRequest.creator.username, achieve); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
module.exports = cuttingEdge; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,68 @@ | ||
var cuttingEdge = | ||
require('../achievements/cuttingEdges.achievement'); | ||
var expect = require('chai').expect; | ||
|
||
describe('Cutting Edges achievement', function() { | ||
it('should not be granted if pull request is not merged', function() { | ||
var testShall = new Shall(); | ||
var pullRequest = new PullRequest(); | ||
|
||
cuttingEdge.check(pullRequest, testShall); | ||
expect(testShall.grantedToUsername).to.not.exist; | ||
expect(testShall.grantedAchievement).to.not.exist; | ||
}); | ||
|
||
it('should not be granted if pull request was merged with approvals', function() { | ||
var testShall = new Shall(); | ||
var pullRequest = new PullRequest(); | ||
|
||
pullRequest.merged = true; | ||
pullRequest.reviews = [ | ||
{ | ||
id: 'review', | ||
state: 'APPROVED', | ||
} | ||
]; | ||
|
||
cuttingEdge.check(pullRequest, testShall); | ||
expect(testShall.grantedToUsername).to.not.exist; | ||
expect(testShall.grantedAchievement).to.not.exist; | ||
}); | ||
|
||
it('should be granted if pull request was merged without approvals', function() { | ||
var testShall = new Shall(); | ||
var pullRequest = new PullRequest(); | ||
|
||
pullRequest.merged = true; | ||
pullRequest.reviews = []; | ||
|
||
cuttingEdge.check(pullRequest, testShall); | ||
expect(testShall.grantedToUsername).to.be.a('string'); | ||
expect(testShall.grantedToUsername).to.equal('creator'); | ||
expect(testShall.grantedAchievement).to.be.an('object'); | ||
}); | ||
}); | ||
|
||
function Shall() { | ||
var self = this; | ||
|
||
self.grantedAchievement = undefined; | ||
self.grantedToUsername = undefined; | ||
|
||
self.grant = function(username, achievementObject) { | ||
self.grantedToUsername = username; | ||
self.grantedAchievement = achievementObject; | ||
}; | ||
} | ||
|
||
function PullRequest() { | ||
return { | ||
'title': 'this is a happy little title', | ||
'id': 'test', | ||
'url': 'url', | ||
'description': '', | ||
'creator': { | ||
'username': 'creator' | ||
} | ||
}; | ||
} |