diff options
author | sming-gitlab <sming@gitlab.com> | 2019-06-11 18:02:15 -0700 |
---|---|---|
committer | sming-gitlab <sming@gitlab.com> | 2019-06-20 09:19:32 -0700 |
commit | 9f80d2be75c68c6f059152fe3e76441fe7ef91c2 (patch) | |
tree | 1d512d6f572ee915761f5a10686aff21c8df1994 | |
parent | c6eb18ee0fe1b887438da87f25fc2f2a852dd393 (diff) | |
download | gitlab-ce-59028-fix-extra-plus-in-diffs.tar.gz |
Add back trimChar method to remove trailing +/-59028-fix-extra-plus-in-diffs
Add test for checking output
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(); |