diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/helpers/diff_helper_spec.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/helpers/diff_helper_spec.rb')
-rw-r--r-- | spec/helpers/diff_helper_spec.rb | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index 29708f10de4..84e702cd6a9 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -290,6 +290,53 @@ RSpec.describe DiffHelper do end end + describe "#diff_nomappinginraw_line" do + using RSpec::Parameterized::TableSyntax + + let(:line) { double("line") } + let(:line_type) { 'line_type' } + + before do + allow(line).to receive(:rich_text).and_return('line_text') + allow(line).to receive(:type).and_return(line_type) + end + + it 'generates only single line num' do + output = diff_nomappinginraw_line(line, ['line_num_1'], nil, ['line_content']) + + expect(output).to be_html_safe + expect(output).to have_css 'td:nth-child(1).line_num_1' + expect(output).to have_css 'td:nth-child(2).line_content', text: 'line_text' + expect(output).not_to have_css 'td:nth-child(3)' + end + + it 'generates only both line nums' do + output = diff_nomappinginraw_line(line, ['line_num_1'], ['line_num_2'], ['line_content']) + + expect(output).to be_html_safe + expect(output).to have_css 'td:nth-child(1).line_num_1' + expect(output).to have_css 'td:nth-child(2).line_num_2' + expect(output).to have_css 'td:nth-child(3).line_content', text: 'line_text' + end + + where(:line_type, :added_class) do + 'old-nomappinginraw' | '.old' + 'new-nomappinginraw' | '.new' + 'unchanged-nomappinginraw' | '' + end + + with_them do + it "appends the correct class" do + output = diff_nomappinginraw_line(line, ['line_num_1'], ['line_num_2'], ['line_content']) + + expect(output).to be_html_safe + expect(output).to have_css 'td:nth-child(1).line_num_1' + added_class + expect(output).to have_css 'td:nth-child(2).line_num_2' + added_class + expect(output).to have_css 'td:nth-child(3).line_content' + added_class, text: 'line_text' + end + end + end + describe '#render_overflow_warning?' do using RSpec::Parameterized::TableSyntax @@ -378,16 +425,6 @@ RSpec.describe DiffHelper do end end - describe '#diff_file_path_text' do - it 'returns full path by default' do - expect(diff_file_path_text(diff_file)).to eq(diff_file.new_path) - end - - it 'returns truncated path' do - expect(diff_file_path_text(diff_file, max: 10)).to eq("...open.rb") - end - end - describe "#collapsed_diff_url" do let(:params) do { |