summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamantha Ming <sming@gitlab.com>2019-06-21 10:10:05 +0000
committerPhil Hughes <me@iamphill.com>2019-06-21 10:10:05 +0000
commit08359a8ebcb7fc2c0f996b43186e826ddbec9554 (patch)
treeb4ddafc9d825f19cf87cf0dc6b791d43646feaf5
parent75b3f26a6c33a373942d14d715b4bdf70c7daad2 (diff)
downloadgitlab-ce-08359a8ebcb7fc2c0f996b43186e826ddbec9554.tar.gz
Add back trimChar method to remove trailing +/-
Add test for checking output
-rw-r--r--app/assets/javascripts/notes/components/diff_with_note.vue7
-rw-r--r--changelogs/unreleased/59028-fix-extra-plus-in-diffs.yml5
-rw-r--r--spec/javascripts/notes/components/diff_with_note_spec.js13
3 files changed, 24 insertions, 1 deletions
diff --git a/app/assets/javascripts/notes/components/diff_with_note.vue b/app/assets/javascripts/notes/components/diff_with_note.vue
index b95835ed10a..54c242b2fda 100644
--- a/app/assets/javascripts/notes/components/diff_with_note.vue
+++ b/app/assets/javascripts/notes/components/diff_with_note.vue
@@ -7,6 +7,8 @@ import { GlSkeletonLoading } from '@gitlab/ui';
import { getDiffMode } from '~/diffs/store/utils';
import { diffViewerModes } from '~/ide/constants';
+const FIRST_CHAR_REGEX = /^(\+|-| )/;
+
export default {
components: {
DiffFileHeader,
@@ -59,6 +61,9 @@ export default {
this.error = true;
});
},
+ trimChar(line) {
+ return line.replace(FIRST_CHAR_REGEX, '');
+ },
},
userColorSchemeClass: window.gon.user_color_scheme,
};
@@ -83,7 +88,7 @@ export default {
>
<td :class="line.type" class="diff-line-num old_line">{{ line.old_line }}</td>
<td :class="line.type" class="diff-line-num new_line">{{ line.new_line }}</td>
- <td :class="line.type" class="line_content" v-html="line.rich_text"></td>
+ <td :class="line.type" class="line_content" v-html="trimChar(line.rich_text)"></td>
</tr>
</template>
<tr v-if="!hasTruncatedDiffLines" class="line_holder line-holder-placeholder">
diff --git a/changelogs/unreleased/59028-fix-extra-plus-in-diffs.yml b/changelogs/unreleased/59028-fix-extra-plus-in-diffs.yml
new file mode 100644
index 00000000000..0786f4dbc10
--- /dev/null
+++ b/changelogs/unreleased/59028-fix-extra-plus-in-diffs.yml
@@ -0,0 +1,5 @@
+---
+title: Remove duplicate trailing +/- char in merge request discussions
+merge_request: 29518
+author:
+type: fixed
diff --git a/spec/javascripts/notes/components/diff_with_note_spec.js b/spec/javascripts/notes/components/diff_with_note_spec.js
index 0752bd05904..f849fe9d8bb 100644
--- a/spec/javascripts/notes/components/diff_with_note_spec.js
+++ b/spec/javascripts/notes/components/diff_with_note_spec.js
@@ -47,6 +47,19 @@ describe('diff_with_note', () => {
vm = mountComponentWithStore(Component, { props, store });
});
+ it('removes trailing "+" char', () => {
+ const richText = vm.$el.querySelectorAll('.line_holder')[4].querySelector('.line_content')
+ .textContent[0];
+
+ expect(richText).not.toEqual('+');
+ });
+
+ it('removes trailing "-" char', () => {
+ const richText = vm.$el.querySelector('#LC13').parentNode.textContent[0];
+
+ expect(richText).not.toEqual('-');
+ });
+
it('shows text diff', () => {
expect(selectors.container).toHaveClass('text-file');
expect(selectors.diffTable).toExist();