gitlab-org--gitlab-foss/spec/lib/gitlab/diff/file_spec.rb
Yorick Peterse 3f0d780c19 Show a notice for diffs that are too large
This builds on the changes introduced in
https://gitlab.com/gitlab-org/gitlab_git/merge_requests/72 and results
in merge requests with large diffs (e.g. due to them containing minified
CSS) loading much faster.
2016-03-18 12:30:46 +01:00

35 lines
962 B
Ruby

require 'spec_helper'
describe Gitlab::Diff::File, lib: true do
include RepoHelpers
let(:project) { create(:project) }
let(:commit) { project.commit(sample_commit.id) }
let(:diff) { commit.diffs.first }
let(:diff_file) { Gitlab::Diff::File.new(diff, [commit.parent, commit]) }
describe :diff_lines do
let(:diff_lines) { diff_file.diff_lines }
it { expect(diff_lines.size).to eq(30) }
it { expect(diff_lines.first).to be_kind_of(Gitlab::Diff::Line) }
end
describe :mode_changed? do
it { expect(diff_file.mode_changed?).to be_falsey }
end
describe '#too_large?' do
it 'returns true for a file that is too large' do
expect(diff).to receive(:too_large?).and_return(true)
expect(diff_file.too_large?).to eq(true)
end
it 'returns false for a file that is small enough' do
expect(diff).to receive(:too_large?).and_return(false)
expect(diff_file.too_large?).to eq(false)
end
end
end