diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /spec/helpers/diff_helper_spec.rb | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) | |
download | gitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/helpers/diff_helper_spec.rb')
-rw-r--r-- | spec/helpers/diff_helper_spec.rb | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index dfea1020c52..29708f10de4 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -293,23 +293,22 @@ RSpec.describe DiffHelper do describe '#render_overflow_warning?' do using RSpec::Parameterized::TableSyntax - let(:diffs_collection) { instance_double(Gitlab::Diff::FileCollection::MergeRequestDiff, raw_diff_files: diff_files) } + let(:diffs_collection) { instance_double(Gitlab::Diff::FileCollection::MergeRequestDiff, raw_diff_files: diff_files, overflow?: false) } let(:diff_files) { Gitlab::Git::DiffCollection.new(files) } let(:safe_file) { { too_large: false, diff: '' } } let(:large_file) { { too_large: true, diff: '' } } let(:files) { [safe_file, safe_file] } - before do - allow(diff_files).to receive(:overflow?).and_return(false) - allow(diff_files).to receive(:overflow_max_bytes?).and_return(false) - allow(diff_files).to receive(:overflow_max_files?).and_return(false) - allow(diff_files).to receive(:overflow_max_lines?).and_return(false) - allow(diff_files).to receive(:collapsed_safe_bytes?).and_return(false) - allow(diff_files).to receive(:collapsed_safe_files?).and_return(false) - allow(diff_files).to receive(:collapsed_safe_lines?).and_return(false) - end - context 'when no limits are hit' do + before do + allow(diff_files).to receive(:overflow_max_bytes?).and_return(false) + allow(diff_files).to receive(:overflow_max_files?).and_return(false) + allow(diff_files).to receive(:overflow_max_lines?).and_return(false) + allow(diff_files).to receive(:collapsed_safe_bytes?).and_return(false) + allow(diff_files).to receive(:collapsed_safe_files?).and_return(false) + allow(diff_files).to receive(:collapsed_safe_lines?).and_return(false) + end + it 'returns false and does not log any overflow events' do expect(Gitlab::Metrics).not_to receive(:add_event).with(:diffs_overflow_collection_limits) expect(Gitlab::Metrics).not_to receive(:add_event).with(:diffs_overflow_single_file_limits) @@ -343,7 +342,7 @@ RSpec.describe DiffHelper do context 'when the file collection has an overflow' do before do - allow(diff_files).to receive(:overflow?).and_return(true) + allow(diffs_collection).to receive(:overflow?).and_return(true) end it 'returns true and only logs all the correct collection overflow event' do @@ -405,7 +404,7 @@ RSpec.describe DiffHelper do it "returns a valid URL" do allow(helper).to receive(:safe_params).and_return(params) - expect(subject).to match(/foo\/bar\/-\/commit\/#{commit.sha}\/diff_for_path/) + expect(subject).to match(%r{foo/bar/-/commit/#{commit.sha}/diff_for_path}) end end |