summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-09-13 12:35:42 +0100
committerPhil Hughes <me@iamphill.com>2018-09-17 09:50:37 +0100
commitef4e3b6ed37e2e1b92c1ab39e5f94d908dddb279 (patch)
tree0d4ce3e3949d35c68bf0019f8279c469be042367
parentf9e290b9dbcc6340d0f8fcf98fabdcdbac3a0b10 (diff)
downloadgitlab-ce-ef4e3b6ed37e2e1b92c1ab39e5f94d908dddb279.tar.gz
Moved legacy diff note check into util method
Un-commented out expect checks in mutation spec
-rw-r--r--app/assets/javascripts/diffs/store/mutations.js4
-rw-r--r--app/assets/javascripts/notes/stores/utils.js7
-rw-r--r--spec/javascripts/diffs/store/mutations_spec.js8
3 files changed, 8 insertions, 11 deletions
diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js
index b6818f905e5..72da64bd4db 100644
--- a/app/assets/javascripts/diffs/store/mutations.js
+++ b/app/assets/javascripts/diffs/store/mutations.js
@@ -1,5 +1,6 @@
import Vue from 'vue';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
+import { isLegacyDiffNote } from '~/notes/stores/utils';
import {
findDiffFile,
addLineReferences,
@@ -90,8 +91,7 @@ export default {
const firstDiscussion = discussions[0];
const isDiffDiscussion = firstDiscussion.diff_discussion;
const hasLineCode = firstDiscussion.line_code;
- const isResolvable =
- firstDiscussion.resolvable || (!firstDiscussion.resolvable && !firstDiscussion.position);
+ const isResolvable = firstDiscussion.resolvable || isLegacyDiffNote(firstDiscussion);
const diffPosition = diffPositionByLineCode[firstDiscussion.line_code];
if (
diff --git a/app/assets/javascripts/notes/stores/utils.js b/app/assets/javascripts/notes/stores/utils.js
index e2dd81273f5..eea6eb2b1af 100644
--- a/app/assets/javascripts/notes/stores/utils.js
+++ b/app/assets/javascripts/notes/stores/utils.js
@@ -2,6 +2,7 @@ import AjaxCache from '~/lib/utils/ajax_cache';
const REGEX_QUICK_ACTIONS = /^\/\w+.*$/gm;
+export const isLegacyDiffNote = note => !note.resolvable && !note.position;
export const findNoteObjectById = (notes, id) => notes.filter(n => n.id === id)[0];
export const getQuickActionText = note => {
@@ -27,11 +28,7 @@ export const getQuickActionText = note => {
export const reduceDiscussionsToLineCodes = selectedDiscussions =>
selectedDiscussions.reduce((acc, note) => {
- if (
- note.diff_discussion &&
- note.line_code &&
- (note.resolvable || (!note.resolvable && !note.position))
- ) {
+ if (note.diff_discussion && note.line_code && (note.resolvable || isLegacyDiffNote(note))) {
// For context about line notes: there might be multiple notes with the same line code
const items = acc[note.line_code] || [];
items.push(note);
diff --git a/spec/javascripts/diffs/store/mutations_spec.js b/spec/javascripts/diffs/store/mutations_spec.js
index a969483bffb..8e94b21f737 100644
--- a/spec/javascripts/diffs/store/mutations_spec.js
+++ b/spec/javascripts/diffs/store/mutations_spec.js
@@ -290,11 +290,11 @@ describe('DiffsStoreMutations', () => {
diffPositionByLineCode,
});
- // expect(state.diffFiles[0].parallelDiffLines[0].left.discussions.length).toEqual(2);
- // expect(state.diffFiles[0].parallelDiffLines[0].left.discussions[1].id).toEqual(2);
+ expect(state.diffFiles[0].parallelDiffLines[0].left.discussions.length).toEqual(2);
+ expect(state.diffFiles[0].parallelDiffLines[0].left.discussions[1].id).toEqual(2);
- // expect(state.diffFiles[0].highlightedDiffLines[0].discussions.length).toEqual(2);
- // expect(state.diffFiles[0].highlightedDiffLines[0].discussions[1].id).toEqual(2);
+ expect(state.diffFiles[0].highlightedDiffLines[0].discussions.length).toEqual(2);
+ expect(state.diffFiles[0].highlightedDiffLines[0].discussions[1].id).toEqual(2);
});
});