From 3fe18525ddca414017d330e992999bad05002fa8 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sun, 31 Jul 2016 20:51:12 -0700 Subject: Trim extra displayed carriage returns in diffs and files with CRLFs Closes #20440 --- spec/lib/gitlab/highlight_spec.rb | 12 ++++++++++++ spec/support/test_env.rb | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/lib/gitlab/highlight_spec.rb b/spec/lib/gitlab/highlight_spec.rb index 364532e94e3..80a9473d6aa 100644 --- a/spec/lib/gitlab/highlight_spec.rb +++ b/spec/lib/gitlab/highlight_spec.rb @@ -17,6 +17,18 @@ describe Gitlab::Highlight, lib: true do expect(lines[21]).to eq(%Q{ unless File.directory?(path)\n}) expect(lines[26]).to eq(%Q{ @cmd_status = 0\n}) end + + describe 'with CRLF' do + let(:branch) { 'crlf-diff' } + let(:blob) { repository.blob_at_branch(branch, path) } + let(:lines) do + Gitlab::Highlight.highlight_lines(project.repository, 'crlf-diff-test', 'files/whitespace') + end + + it 'strips extra LFs' do + expect(lines[0]).to eq("test ") + end + end end describe 'custom highlighting from .gitattributes' do diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index 3735abe2302..4561aa9644d 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -21,7 +21,8 @@ module TestEnv 'expand-collapse-diffs' => '4842455', 'expand-collapse-files' => '025db92', 'expand-collapse-lines' => '238e82d', - 'video' => '8879059' + 'video' => '8879059', + 'crlf-diff' => '5938907' } # gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily -- cgit v1.2.1 From fe25d1d5cfdd8c52854b459b49bbead1a608822c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Mon, 1 Aug 2016 13:16:04 +0200 Subject: Fix specs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- spec/finders/branches_finder_spec.rb | 2 +- spec/lib/gitlab/highlight_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/finders/branches_finder_spec.rb b/spec/finders/branches_finder_spec.rb index 6ea9a3a3ec5..482caeee64a 100644 --- a/spec/finders/branches_finder_spec.rb +++ b/spec/finders/branches_finder_spec.rb @@ -20,7 +20,7 @@ describe BranchesFinder do result = branches_finder.execute - expect(result.first.name).to eq('video') + expect(result.first.name).to eq('crlf-diff') end it 'sorts by last_updated' do diff --git a/spec/lib/gitlab/highlight_spec.rb b/spec/lib/gitlab/highlight_spec.rb index 80a9473d6aa..fc021416d92 100644 --- a/spec/lib/gitlab/highlight_spec.rb +++ b/spec/lib/gitlab/highlight_spec.rb @@ -22,7 +22,7 @@ describe Gitlab::Highlight, lib: true do let(:branch) { 'crlf-diff' } let(:blob) { repository.blob_at_branch(branch, path) } let(:lines) do - Gitlab::Highlight.highlight_lines(project.repository, 'crlf-diff-test', 'files/whitespace') + Gitlab::Highlight.highlight_lines(project.repository, 'crlf-diff', 'files/whitespace') end it 'strips extra LFs' do -- cgit v1.2.1