2017-02-15 21:08:30 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::GitalyClient::Ref do
|
|
|
|
let(:project) { create(:empty_project) }
|
2017-06-12 17:37:43 -04:00
|
|
|
let(:storage_name) { project.repository_storage }
|
|
|
|
let(:relative_path) { project.path_with_namespace + '.git' }
|
2017-05-01 11:13:33 -04:00
|
|
|
let(:client) { described_class.new(project.repository) }
|
2017-02-15 21:08:30 -05:00
|
|
|
|
|
|
|
describe '#branch_names' do
|
|
|
|
it 'sends a find_all_branch_names message' do
|
2017-06-21 09:48:12 -04:00
|
|
|
expect_any_instance_of(Gitaly::Ref::Stub)
|
|
|
|
.to receive(:find_all_branch_names)
|
|
|
|
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
|
|
|
|
.and_return([])
|
2017-02-15 21:08:30 -05:00
|
|
|
|
|
|
|
client.branch_names
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#tag_names' do
|
|
|
|
it 'sends a find_all_tag_names message' do
|
2017-06-21 09:48:12 -04:00
|
|
|
expect_any_instance_of(Gitaly::Ref::Stub)
|
|
|
|
.to receive(:find_all_tag_names)
|
|
|
|
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
|
|
|
|
.and_return([])
|
2017-02-15 21:08:30 -05:00
|
|
|
|
|
|
|
client.tag_names
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#default_branch_name' do
|
|
|
|
it 'sends a find_default_branch_name message' do
|
2017-06-21 09:48:12 -04:00
|
|
|
expect_any_instance_of(Gitaly::Ref::Stub)
|
|
|
|
.to receive(:find_default_branch_name)
|
|
|
|
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
|
|
|
|
.and_return(double(name: 'foo'))
|
2017-02-15 21:08:30 -05:00
|
|
|
|
|
|
|
client.default_branch_name
|
|
|
|
end
|
|
|
|
end
|
2017-03-17 15:36:46 -04:00
|
|
|
|
|
|
|
describe '#local_branches' do
|
|
|
|
it 'sends a find_local_branches message' do
|
2017-06-21 09:48:12 -04:00
|
|
|
expect_any_instance_of(Gitaly::Ref::Stub)
|
|
|
|
.to receive(:find_local_branches)
|
|
|
|
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
|
|
|
|
.and_return([])
|
2017-03-17 15:36:46 -04:00
|
|
|
|
|
|
|
client.local_branches
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'parses and sends the sort parameter' do
|
2017-06-21 09:48:12 -04:00
|
|
|
expect_any_instance_of(Gitaly::Ref::Stub)
|
|
|
|
.to receive(:find_local_branches)
|
|
|
|
.with(gitaly_request_with_params(sort_by: :UPDATED_DESC), kind_of(Hash))
|
|
|
|
.and_return([])
|
2017-03-17 15:36:46 -04:00
|
|
|
|
|
|
|
client.local_branches(sort_by: 'updated_desc')
|
|
|
|
end
|
|
|
|
|
2017-06-28 15:38:00 -04:00
|
|
|
it 'translates known mismatches on sort param values' do
|
|
|
|
expect_any_instance_of(Gitaly::Ref::Stub)
|
|
|
|
.to receive(:find_local_branches)
|
|
|
|
.with(gitaly_request_with_params(sort_by: :NAME), kind_of(Hash))
|
|
|
|
.and_return([])
|
|
|
|
|
|
|
|
client.local_branches(sort_by: 'name_asc')
|
|
|
|
end
|
|
|
|
|
2017-03-17 15:36:46 -04:00
|
|
|
it 'raises an argument error if an invalid sort_by parameter is passed' do
|
|
|
|
expect { client.local_branches(sort_by: 'invalid_sort') }.to raise_error(ArgumentError)
|
|
|
|
end
|
|
|
|
end
|
2017-06-29 08:11:42 -04:00
|
|
|
|
|
|
|
describe '#find_ref_name', seed_helper: true do
|
|
|
|
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) }
|
|
|
|
let(:client) { described_class.new(repository) }
|
|
|
|
subject { client.find_ref_name(SeedRepo::Commit::ID, 'refs/heads/master') }
|
|
|
|
|
2017-07-05 16:12:10 -04:00
|
|
|
it { is_expected.to be_utf8 }
|
|
|
|
it { is_expected.to eq('refs/heads/master') }
|
2017-06-29 08:11:42 -04:00
|
|
|
end
|
2017-02-15 21:08:30 -05:00
|
|
|
end
|