Skip to content

Commit

Permalink
Merge branch 'master' into subject-writer-typo
Browse files Browse the repository at this point in the history
  • Loading branch information
iamigo committed Mar 24, 2017
2 parents b552153 + b04a427 commit c6d769e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions api/v1/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7413,6 +7413,7 @@ parameters:
- isPublished
- name
- sortBy
- tags
- parentAbsolutePath
- parentId
- relatedLinks
Expand Down
1 change: 0 additions & 1 deletion db/model/sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ module.exports = function sample(seq, dataTypes) {

/**
* Update isDeleted.
* Publishes the deleted sample to redis channel.
*
* @param {Sample} inst - The Sample instance being deleted
* @returns {Promise} which resolves undefined or rejects if an error
Expand Down
12 changes: 7 additions & 5 deletions db/model/subject.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,15 +408,17 @@ module.exports = function subject(seq, dataTypes) {
if (inst.getDataValue('isPublished')) {
if (inst.previous('isPublished')) {
/*
* If tags were updated, send a "delete" event followed by an "add"
* event so that perspectives using subject tag filters will get
* the right realtime events. If subject tags were not updated,
* just send the usual "update" event.
* If tags OR parent were updated, send a "delete" event followed
* by an "add" event so that perspectives get notified and lenses
* can re-render correctly. Tag changes have to be handled this
* way for filtering.
* If subject tags or parent were not updated, just send the usual
* "update" event.
*
* TODO : Right now don't have the ability to mock the socket.io
* test for this.
*/
if (inst.changed('tags')) {
if (inst.changed('tags') || inst.changed('parentId')) {
common.publishChange(inst, eventName.del, changedKeys,
ignoreAttributes);
common.publishChange(inst, eventName.add, changedKeys,
Expand Down
17 changes: 16 additions & 1 deletion tests/api/v1/subjects/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,25 @@ describe(`api: GET ${path}`, () => {
});
});

it('returns expected fields when requesting tags field', (done) => {
api.get(`${path}?fields=isPublished,name,tags`)
.set('Authorization', token)
.expect(constants.httpStatus.OK)
.end((err, res) => {
if (err) {
done(err);
}

expect(res.body[ZERO]).to.have.property('tags');
expect(res.body[ZERO]).to.have.property('name');
expect(res.body[ZERO]).to.have.property('isPublished');
done();
});
});

it('pagination tests');
it('childCount, descendentCount');
it('by id');
it('by abs path');
it('returns expected fields when NOT passing ?fields=...');
it('sort order');
});

0 comments on commit c6d769e

Please sign in to comment.