summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2018-12-17 12:51:50 +0000
committerFatih Acet <acetfatih@gmail.com>2018-12-17 12:51:50 +0000
commit2f4fe2b503044fd2da39acd96b855a597a61ea29 (patch)
tree99b11a3ae2be20c8a30cdd57af173b0d054c5c7f
parent19fec9a800eca581ecbc4b17012dfd5e720ed3f2 (diff)
parente64c9c211245f9acac422e38673d7a7e77f1801d (diff)
downloadgitlab-ce-2f4fe2b503044fd2da39acd96b855a597a61ea29.tar.gz
Merge branch 'inline-duplicated-discussions' into 'master'
Fixed duplicated inline diff discussions Closes #55388 See merge request gitlab-org/gitlab-ce!23843
-rw-r--r--app/assets/javascripts/diffs/store/mutations.js2
-rw-r--r--spec/javascripts/diffs/store/mutations_spec.js65
2 files changed, 66 insertions, 1 deletions
diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js
index 2ea884d1293..ed4203cf5e0 100644
--- a/app/assets/javascripts/diffs/store/mutations.js
+++ b/app/assets/javascripts/diffs/store/mutations.js
@@ -138,7 +138,7 @@ export default {
if (file.highlighted_diff_lines) {
file.highlighted_diff_lines = file.highlighted_diff_lines.map(line =>
- mapDiscussions(line),
+ lineCheck(line) ? mapDiscussions(line) : line,
);
}
diff --git a/spec/javascripts/diffs/store/mutations_spec.js b/spec/javascripts/diffs/store/mutations_spec.js
index f3449bec6ec..d8733941181 100644
--- a/spec/javascripts/diffs/store/mutations_spec.js
+++ b/spec/javascripts/diffs/store/mutations_spec.js
@@ -358,6 +358,71 @@ describe('DiffsStoreMutations', () => {
expect(state.diffFiles[0].highlighted_diff_lines[0].discussions[0].resolved).toBe(true);
});
+ it('should not duplicate inline diff discussions', () => {
+ const diffPosition = {
+ base_sha: 'ed13df29948c41ba367caa757ab3ec4892509910',
+ head_sha: 'b921914f9a834ac47e6fd9420f78db0f83559130',
+ new_line: null,
+ new_path: '500-lines-4.txt',
+ old_line: 5,
+ old_path: '500-lines-4.txt',
+ start_sha: 'ed13df29948c41ba367caa757ab3ec4892509910',
+ };
+
+ const state = {
+ latestDiff: true,
+ diffFiles: [
+ {
+ file_hash: 'ABC',
+ highlighted_diff_lines: [
+ {
+ line_code: 'ABC_1',
+ discussions: [
+ {
+ id: 1,
+ line_code: 'ABC_1',
+ diff_discussion: true,
+ resolvable: true,
+ original_position: diffPosition,
+ position: diffPosition,
+ diff_file: {
+ file_hash: 'ABC',
+ },
+ },
+ ],
+ },
+ {
+ line_code: 'ABC_2',
+ discussions: [],
+ },
+ ],
+ },
+ ],
+ };
+ const discussion = {
+ id: 2,
+ line_code: 'ABC_2',
+ diff_discussion: true,
+ resolvable: true,
+ original_position: diffPosition,
+ position: diffPosition,
+ diff_file: {
+ file_hash: state.diffFiles[0].file_hash,
+ },
+ };
+
+ const diffPositionByLineCode = {
+ ABC_2: diffPosition,
+ };
+
+ mutations[types.SET_LINE_DISCUSSIONS_FOR_FILE](state, {
+ discussion,
+ diffPositionByLineCode,
+ });
+
+ expect(state.diffFiles[0].highlighted_diff_lines[0].discussions.length).toBe(1);
+ });
+
it('should add legacy discussions to the given line', () => {
const diffPosition = {
base_sha: 'ed13df29948c41ba367caa757ab3ec4892509910',