Commit ef4e3b6e authored by Phil Hughes's avatar Phil Hughes

Moved legacy diff note check into util method

Un-commented out expect checks in mutation spec
parent f9e290b9
import Vue from 'vue'; import Vue from 'vue';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import { isLegacyDiffNote } from '~/notes/stores/utils';
import { import {
findDiffFile, findDiffFile,
addLineReferences, addLineReferences,
...@@ -90,8 +91,7 @@ export default { ...@@ -90,8 +91,7 @@ export default {
const firstDiscussion = discussions[0]; const firstDiscussion = discussions[0];
const isDiffDiscussion = firstDiscussion.diff_discussion; const isDiffDiscussion = firstDiscussion.diff_discussion;
const hasLineCode = firstDiscussion.line_code; const hasLineCode = firstDiscussion.line_code;
const isResolvable = const isResolvable = firstDiscussion.resolvable || isLegacyDiffNote(firstDiscussion);
firstDiscussion.resolvable || (!firstDiscussion.resolvable && !firstDiscussion.position);
const diffPosition = diffPositionByLineCode[firstDiscussion.line_code]; const diffPosition = diffPositionByLineCode[firstDiscussion.line_code];
if ( if (
......
...@@ -2,6 +2,7 @@ import AjaxCache from '~/lib/utils/ajax_cache'; ...@@ -2,6 +2,7 @@ import AjaxCache from '~/lib/utils/ajax_cache';
const REGEX_QUICK_ACTIONS = /^\/\w+.*$/gm; 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 findNoteObjectById = (notes, id) => notes.filter(n => n.id === id)[0];
export const getQuickActionText = note => { export const getQuickActionText = note => {
...@@ -27,11 +28,7 @@ export const getQuickActionText = note => { ...@@ -27,11 +28,7 @@ export const getQuickActionText = note => {
export const reduceDiscussionsToLineCodes = selectedDiscussions => export const reduceDiscussionsToLineCodes = selectedDiscussions =>
selectedDiscussions.reduce((acc, note) => { selectedDiscussions.reduce((acc, note) => {
if ( if (note.diff_discussion && note.line_code && (note.resolvable || isLegacyDiffNote(note))) {
note.diff_discussion &&
note.line_code &&
(note.resolvable || (!note.resolvable && !note.position))
) {
// For context about line notes: there might be multiple notes with the same line code // For context about line notes: there might be multiple notes with the same line code
const items = acc[note.line_code] || []; const items = acc[note.line_code] || [];
items.push(note); items.push(note);
......
...@@ -290,11 +290,11 @@ describe('DiffsStoreMutations', () => { ...@@ -290,11 +290,11 @@ describe('DiffsStoreMutations', () => {
diffPositionByLineCode, diffPositionByLineCode,
}); });
// expect(state.diffFiles[0].parallelDiffLines[0].left.discussions.length).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].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.length).toEqual(2);
// expect(state.diffFiles[0].highlightedDiffLines[0].discussions[1].id).toEqual(2); expect(state.diffFiles[0].highlightedDiffLines[0].discussions[1].id).toEqual(2);
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment