debian-mirror-gitlab/spec/lib/gitlab/diff/file_spec.rb

50 lines
1.4 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
require 'spec_helper'
2015-12-23 02:04:40 +05:30
describe Gitlab::Diff::File, lib: true do
2015-04-26 12:48:37 +05:30
include RepoHelpers
let(:project) { create(:project) }
2015-09-11 14:41:01 +05:30
let(:commit) { project.commit(sample_commit.id) }
2015-04-26 12:48:37 +05:30
let(:diff) { commit.diffs.first }
2016-08-24 12:49:21 +05:30
let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: commit.diff_refs, repository: project.repository) }
2015-04-26 12:48:37 +05:30
2016-08-24 12:49:21 +05:30
describe '#diff_lines' do
2015-04-26 12:48:37 +05:30
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
2016-08-24 12:49:21 +05:30
describe '#mode_changed?' do
2015-04-26 12:48:37 +05:30
it { expect(diff_file.mode_changed?).to be_falsey }
end
2016-06-02 11:05:42 +05:30
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
2016-08-24 12:49:21 +05:30
describe '#collapsed?' do
it 'returns true for a file that is quite big' do
expect(diff).to receive(:collapsed?).and_return(true)
expect(diff_file.collapsed?).to eq(true)
end
it 'returns false for a file that is small enough' do
expect(diff).to receive(:collapsed?).and_return(false)
expect(diff_file.collapsed?).to eq(false)
end
end
2015-04-26 12:48:37 +05:30
end