diff options
Diffstat (limited to 'spec/lib/gitlab/gitaly_client/repository_service_spec.rb')
-rw-r--r-- | spec/lib/gitlab/gitaly_client/repository_service_spec.rb | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/spec/lib/gitlab/gitaly_client/repository_service_spec.rb b/spec/lib/gitlab/gitaly_client/repository_service_spec.rb index 434550186c1..f457ba06074 100644 --- a/spec/lib/gitlab/gitaly_client/repository_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/repository_service_spec.rb @@ -275,7 +275,8 @@ RSpec.describe Gitlab::GitalyClient::RepositoryService do it 'sends a create_repository message without arguments' do expect_any_instance_of(Gitaly::RepositoryService::Stub) .to receive(:create_repository) - .with(gitaly_request_with_path(storage_name, relative_path).and(gitaly_request_with_params(default_branch: '')), kind_of(Hash)) + .with(gitaly_request_with_path(storage_name, relative_path) + .and(gitaly_request_with_params(default_branch: '')), kind_of(Hash)) .and_return(double) client.create_repository @@ -284,11 +285,23 @@ RSpec.describe Gitlab::GitalyClient::RepositoryService do it 'sends a create_repository message with default branch' do expect_any_instance_of(Gitaly::RepositoryService::Stub) .to receive(:create_repository) - .with(gitaly_request_with_path(storage_name, relative_path).and(gitaly_request_with_params(default_branch: 'default-branch-name')), kind_of(Hash)) + .with(gitaly_request_with_path(storage_name, relative_path) + .and(gitaly_request_with_params(default_branch: 'default-branch-name')), kind_of(Hash)) .and_return(double) client.create_repository('default-branch-name') end + + it 'sends a create_repository message with default branch containing non ascii chars' do + expect_any_instance_of(Gitaly::RepositoryService::Stub) + .to receive(:create_repository) + .with(gitaly_request_with_path(storage_name, relative_path) + .and(gitaly_request_with_params( + default_branch: Gitlab::EncodingHelper.encode_binary('feature/新機能'))), kind_of(Hash) + ).and_return(double) + + client.create_repository('feature/新機能') + end end describe '#create_from_snapshot' do @@ -314,17 +327,31 @@ RSpec.describe Gitlab::GitalyClient::RepositoryService do end describe '#search_files_by_regexp' do - subject(:result) { client.search_files_by_regexp('master', '.*') } + subject(:result) { client.search_files_by_regexp(ref, '.*') } before do expect_any_instance_of(Gitaly::RepositoryService::Stub) .to receive(:search_files_by_name) - .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) - .and_return([double(files: ['file1.txt']), double(files: ['file2.txt'])]) + .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) + .and_return([double(files: ['file1.txt']), double(files: ['file2.txt'])]) end - it 'sends a search_files_by_name message and returns a flatten array' do - expect(result).to contain_exactly('file1.txt', 'file2.txt') + shared_examples 'a search for files by regexp' do + it 'sends a search_files_by_name message and returns a flatten array' do + expect(result).to contain_exactly('file1.txt', 'file2.txt') + end + end + + context 'with ASCII ref' do + let(:ref) { 'master' } + + it_behaves_like 'a search for files by regexp' + end + + context 'with non-ASCII ref' do + let(:ref) { 'ref-ñéüçæøß-val' } + + it_behaves_like 'a search for files by regexp' end end |