2014-09-29 13:40:13 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Repository do
|
|
|
|
include RepoHelpers
|
|
|
|
|
|
|
|
let(:repository) { create(:project).repository }
|
|
|
|
|
|
|
|
describe :branch_names_contains do
|
|
|
|
subject { repository.branch_names_contains(sample_commit.id) }
|
|
|
|
|
2015-02-12 18:17:35 +00:00
|
|
|
it { is_expected.to include('master') }
|
|
|
|
it { is_expected.not_to include('feature') }
|
|
|
|
it { is_expected.not_to include('fix') }
|
2014-09-29 13:40:13 +00:00
|
|
|
end
|
2014-09-29 13:45:16 +00:00
|
|
|
|
2015-03-22 18:01:45 +00:00
|
|
|
describe :tag_names_contains do
|
|
|
|
subject { repository.tag_names_contains(sample_commit.id) }
|
2015-03-09 22:10:59 +00:00
|
|
|
|
2015-03-22 18:01:45 +00:00
|
|
|
it { is_expected.to include('v1.1.0') }
|
|
|
|
it { is_expected.not_to include('v1.0.0') }
|
2015-03-13 10:39:26 +00:00
|
|
|
end
|
|
|
|
|
2015-03-22 18:01:45 +00:00
|
|
|
describe :last_commit_for_path do
|
|
|
|
subject { repository.last_commit_for_path(sample_commit.id, '.gitignore').id }
|
2015-03-13 10:39:26 +00:00
|
|
|
|
2015-03-22 18:01:45 +00:00
|
|
|
it { is_expected.to eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') }
|
2015-03-09 22:10:59 +00:00
|
|
|
end
|
2015-07-01 09:02:37 +00:00
|
|
|
|
2015-10-28 01:16:56 +00:00
|
|
|
describe :find_commits_with_matching_log do
|
2015-10-29 02:12:22 +00:00
|
|
|
subject { repository.find_commits_with_matching_log('submodule').map{ |k| k.id } }
|
2015-06-14 22:04:20 +00:00
|
|
|
|
|
|
|
it { is_expected.to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
|
|
|
|
it { is_expected.to include('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
|
|
|
|
it { is_expected.to include('cfe32cf61b73a0d5e9f13e774abde7ff789b1660') }
|
|
|
|
it { is_expected.not_to include('913c66a37b4a45b9769037c55c2d238bd0942d2e') }
|
|
|
|
end
|
|
|
|
|
2015-07-01 09:02:37 +00:00
|
|
|
describe :blob_at do
|
|
|
|
context 'blank sha' do
|
|
|
|
subject { repository.blob_at(Gitlab::Git::BLANK_SHA, '.gitignore') }
|
|
|
|
|
|
|
|
it { is_expected.to be_nil }
|
|
|
|
end
|
|
|
|
end
|
2015-07-01 15:24:03 +00:00
|
|
|
|
2015-08-09 18:31:50 +00:00
|
|
|
describe :merged_to_root_ref? do
|
|
|
|
context 'merged branch' do
|
|
|
|
subject { repository.merged_to_root_ref?('improve/awesome') }
|
|
|
|
|
|
|
|
it { is_expected.to be_truthy }
|
|
|
|
end
|
2015-08-17 09:41:53 +00:00
|
|
|
end
|
|
|
|
|
2015-08-11 12:33:31 +00:00
|
|
|
describe :can_be_merged? do
|
|
|
|
context 'mergeable branches' do
|
|
|
|
subject { repository.can_be_merged?('0b4bc9a49b562e85de7cc9e834518ea6828729b9', 'master') }
|
|
|
|
|
|
|
|
it { is_expected.to be_truthy }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'non-mergeable branches' do
|
|
|
|
subject { repository.can_be_merged?('bb5206fee213d983da88c47f9cf4cc6caf9c66dc', 'feature') }
|
|
|
|
|
|
|
|
it { is_expected.to be_falsey }
|
|
|
|
end
|
2015-08-09 18:31:50 +00:00
|
|
|
|
|
|
|
context 'non merged branch' do
|
|
|
|
subject { repository.merged_to_root_ref?('fix') }
|
|
|
|
|
|
|
|
it { is_expected.to be_falsey }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'non existent branch' do
|
|
|
|
subject { repository.merged_to_root_ref?('non_existent_branch') }
|
|
|
|
|
|
|
|
it { is_expected.to be_nil }
|
|
|
|
end
|
2015-08-11 12:33:31 +00:00
|
|
|
end
|
|
|
|
|
2015-07-12 12:32:25 +00:00
|
|
|
describe "search_files" do
|
|
|
|
let(:results) { repository.search_files('feature', 'master') }
|
|
|
|
subject { results }
|
|
|
|
|
|
|
|
it { is_expected.to be_an Array }
|
|
|
|
|
|
|
|
describe 'result' do
|
|
|
|
subject { results.first }
|
|
|
|
|
|
|
|
it { is_expected.to be_an String }
|
|
|
|
it { expect(subject.lines[2]).to eq("master:CHANGELOG:188: - Feature: Replace teams with group membership\n") }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'parsing result' do
|
|
|
|
subject { repository.parse_search_result(results.first) }
|
|
|
|
|
|
|
|
it { is_expected.to be_an OpenStruct }
|
|
|
|
it { expect(subject.filename).to eq('CHANGELOG') }
|
|
|
|
it { expect(subject.ref).to eq('master') }
|
|
|
|
it { expect(subject.startline).to eq(186) }
|
|
|
|
it { expect(subject.data.lines[2]).to eq(" - Feature: Replace teams with group membership\n") }
|
|
|
|
end
|
|
|
|
end
|
2015-10-25 02:41:51 +00:00
|
|
|
end
|