From 00f09d9e754f8b9fe0cc812b762b8ddcfc2da38d Mon Sep 17 00:00:00 2001 From: snewcomer24 Date: Tue, 26 Dec 2017 12:25:08 -0800 Subject: [PATCH] add project to conversation --- app/components/conversations/new-conversation-modal.js | 2 +- app/models/conversation.js | 1 + .../components/conversations/new-conversation-modal-test.js | 3 ++- tests/unit/models/conversation-test.js | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/components/conversations/new-conversation-modal.js b/app/components/conversations/new-conversation-modal.js index d2c8d975d..869ade520 100644 --- a/app/components/conversations/new-conversation-modal.js +++ b/app/components/conversations/new-conversation-modal.js @@ -36,7 +36,7 @@ export default Component.extend({ project }); - let conversation = store.createRecord('conversation', { user }); + let conversation = store.createRecord('conversation', { user, project }); get(message, 'conversations').pushObject(conversation); diff --git a/app/models/conversation.js b/app/models/conversation.js index 54d08838c..5f5d9c0a9 100644 --- a/app/models/conversation.js +++ b/app/models/conversation.js @@ -10,5 +10,6 @@ export default Model.extend({ conversationParts: hasMany('conversation-part', { async: true }), message: belongsTo('message', { async: true }), + project: belongsTo('project', { async: true }), user: belongsTo('user', { async: true }) }); diff --git a/tests/integration/components/conversations/new-conversation-modal-test.js b/tests/integration/components/conversations/new-conversation-modal-test.js index 376ca919f..57794c8ab 100644 --- a/tests/integration/components/conversations/new-conversation-modal-test.js +++ b/tests/integration/components/conversations/new-conversation-modal-test.js @@ -34,7 +34,7 @@ moduleForComponent('conversations/new-conversation-modal', 'Integration | Compon }); test('it initiates a conversation and opens the modal when open button is clicked', function(assert) { - assert.expect(6); + assert.expect(7); let store = get(this, 'store'); @@ -55,6 +55,7 @@ test('it initiates a conversation and opens the modal when open button is clicke assert.equal(get(message, 'project.id'), 'foo'); assert.equal(get(message, 'conversations.firstObject.user.id'), 'bar'); + assert.equal(get(message, 'conversations.firstObject.project.id'), 'foo'); assert.equal(get(message, 'author.id'), 'baz'); assert.equal(get(message, 'initiatedBy'), 'admin'); }); diff --git a/tests/unit/models/conversation-test.js b/tests/unit/models/conversation-test.js index a53d4ed0e..f801168c2 100644 --- a/tests/unit/models/conversation-test.js +++ b/tests/unit/models/conversation-test.js @@ -17,4 +17,5 @@ test('it exists', function(assert) { testForAttributes('conversation', ['insertedAt', 'readAt', 'status', 'updatedAt']); testForBelongsTo('conversation', 'message'); +testForBelongsTo('conversation', 'project'); testForBelongsTo('conversation', 'user');