Only show conributors with Kredits in list
This commit is contained in:
@@ -43,8 +43,14 @@ export default Ember.Controller.extend({
|
||||
proposalsClosedSorted: Ember.computed.sort('proposalsClosed', 'proposalsSorting'),
|
||||
proposalsOpenSorted: Ember.computed.sort('proposalsOpen', 'proposalsSorting'),
|
||||
|
||||
contributorsWithKredits: function() {
|
||||
return this.get('model.contributors').filter(c => {
|
||||
return c.get('kredits') !== 0;
|
||||
});
|
||||
}.property('model.contributors.[]'),
|
||||
|
||||
contributorsSorting: ['kredits:desc'],
|
||||
contributorsSorted: Ember.computed.sort('model.contributors', 'contributorsSorting'),
|
||||
contributorsSorted: Ember.computed.sort('contributorsWithKredits', 'contributorsSorting'),
|
||||
|
||||
watchContractEvents: function() {
|
||||
let events = this.get('kredits.kreditsContract')
|
||||
|
||||
@@ -1,11 +1,39 @@
|
||||
// import { moduleFor, test } from 'ember-qunit';
|
||||
//
|
||||
// moduleFor('controller:index', 'Unit | Controller | index');
|
||||
import Ember from 'ember';
|
||||
import Contributor from 'kredits-web/models/contributor';
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
// let addFixtures = function(controller) {
|
||||
// controller.set('model', { contributors: [
|
||||
// { github_username: "neo", github_uid: "318", kredits: 10000 },
|
||||
// { github_username: "morpheus", github_uid: "843", kredits: 15000 },
|
||||
// { github_username: "mouse", github_uid: "842", kredits: 5000 },
|
||||
// ]});
|
||||
// };
|
||||
const {
|
||||
isPresent,
|
||||
isEmpty
|
||||
} = Ember;
|
||||
|
||||
moduleFor('controller:index', 'Unit | Controller | index', {
|
||||
needs: ['service:ipfs', 'service:kredits']
|
||||
});
|
||||
|
||||
let addFixtures = function(controller) {
|
||||
controller.set('model', {
|
||||
contributors: [],
|
||||
proposals: []
|
||||
});
|
||||
|
||||
[
|
||||
{ github_username: "neo", github_uid: "318", kredits: 10000 },
|
||||
{ github_username: "morpheus", github_uid: "843", kredits: 15000 },
|
||||
{ github_username: "trinity", github_uid: "123", kredits: 5000 },
|
||||
{ github_username: "mouse", github_uid: "696", kredits: 0 }
|
||||
].forEach(fixture => {
|
||||
controller.get('model.contributors').push(Contributor.create(fixture));
|
||||
});
|
||||
};
|
||||
|
||||
test('doesn\'t contain people with 0 kredits', function(assert) {
|
||||
let controller = this.subject();
|
||||
addFixtures(controller);
|
||||
|
||||
let contributorsSorted = controller.get('contributorsSorted');
|
||||
console.log(controller.get('contributorsSorted'));
|
||||
|
||||
assert.ok(isPresent(contributorsSorted.findBy('github_username', 'neo')));
|
||||
assert.ok(isEmpty(contributorsSorted.findBy('github_username', 'mouse')));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user