diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-09-20 12:51:14 +0000 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-10-02 18:04:19 +0200 |
commit | 314488aed71653364e3f895093c2e1087c61f1ee (patch) | |
tree | f299c5df4640349db8b43702615d6e78df86f1f8 | |
parent | a9356ceed26cd445b89dec8185d973d4897bced5 (diff) | |
download | gitlab-ce-314488aed71653364e3f895093c2e1087c61f1ee.tar.gz |
Merge branch 'mr-discussion-expanding-bug-fixes' into 'master'
Fixed hidden truncated diff lines not showing when expanded
See merge request gitlab-org/gitlab-ce!21801
-rw-r--r-- | app/assets/javascripts/notes/stores/mutations.js | 5 | ||||
-rw-r--r-- | spec/javascripts/notes/stores/mutation_spec.js | 35 |
2 files changed, 39 insertions, 1 deletions
diff --git a/app/assets/javascripts/notes/stores/mutations.js b/app/assets/javascripts/notes/stores/mutations.js index 16bb54be126..f1242a0d8be 100644 --- a/app/assets/javascripts/notes/stores/mutations.js +++ b/app/assets/javascripts/notes/stores/mutations.js @@ -100,7 +100,10 @@ export default { discussionsData.forEach(discussion => { if (discussion.diff_file) { - Object.assign(discussion, { fileHash: discussion.diff_file.file_hash }); + Object.assign(discussion, { + fileHash: discussion.diff_file.file_hash, + truncated_diff_lines: discussion.truncated_diff_lines || [], + }); } // To support legacy notes, should be very rare case. diff --git a/spec/javascripts/notes/stores/mutation_spec.js b/spec/javascripts/notes/stores/mutation_spec.js index 6b7f61468d5..1ecfe914859 100644 --- a/spec/javascripts/notes/stores/mutation_spec.js +++ b/spec/javascripts/notes/stores/mutation_spec.js @@ -156,6 +156,41 @@ describe('Notes Store mutations', () => { expect(state.discussions[2].notes[0].note).toBe(legacyNote.notes[1].note); expect(state.discussions.length).toEqual(3); }); + + it('adds truncated_diff_lines if discussion is a diffFile', () => { + const state = { + discussions: [], + }; + + mutations.SET_INITIAL_DISCUSSIONS(state, [ + { + ...note, + diff_file: { + file_hash: 'a', + }, + truncated_diff_lines: ['a'], + }, + ]); + + expect(state.discussions[0].truncated_diff_lines).toEqual(['a']); + }); + + it('adds empty truncated_diff_lines when not in discussion', () => { + const state = { + discussions: [], + }; + + mutations.SET_INITIAL_DISCUSSIONS(state, [ + { + ...note, + diff_file: { + file_hash: 'a', + }, + }, + ]); + + expect(state.discussions[0].truncated_diff_lines).toEqual([]); + }); }); describe('SET_LAST_FETCHED_AT', () => { |