diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-07-06 15:54:41 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-07-06 15:54:41 +0800 |
commit | ef7deb18df2b97734e98c22aff53608e4e098bc5 (patch) | |
tree | ab86b4ce8671b13673f86d002c3b2386a7dcf0e9 /spec/lib/gitlab/gitaly_client | |
parent | 6fe2b79656cca21f9f1cea504e5cbb58a51a05ab (diff) | |
parent | 7f500acb5f38f0ae5d4e2d51e27b6257e0800c3d (diff) | |
download | gitlab-ce-ef7deb18df2b97734e98c22aff53608e4e098bc5.tar.gz |
Merge remote-tracking branch 'upstream/master' into 33360-generate-kubeconfig
* upstream/master: (888 commits)
Fix Rubocop offense
Use a previous approach for cycle analytics dummy pipeline
Allow admin to disable all restricted visibility levels
Removes file_name_regex from Gitlab::Regex
Remove IIFEs around several javascript classes
Update CHANGELOG.md for 9.3.5
Add ProjectPathHelper cop
Create and use project path helpers that only need a project, no namespace
Handles realtime with 2 states for environments table
Revert "Merge branch '18000-remember-me-for-oauth-login' into 'master'"
Allow creation of files and directories with spaces in web UI
Disable Flipper memoizer in tests to avoid transient failures
Introduce cache policies for CI jobs
fix sidebar padding for full-width items (Time Tracking help)
Replace 'snippets/snippets.feature' spinach with rspec
Rename ci_config_file to ci_config_path
Add back Pipeline#ci_yaml_file_path due to all the troubles
Revert change to design. Go back to scrollable page
Fix cycle analytics tests by making pipeline valid
Fixes the column widths for the new navigation options in settings
...
Diffstat (limited to 'spec/lib/gitlab/gitaly_client')
-rw-r--r-- | spec/lib/gitlab/gitaly_client/commit_spec.rb | 8 | ||||
-rw-r--r-- | spec/lib/gitlab/gitaly_client/notifications_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/gitaly_client/ref_spec.rb | 69 |
3 files changed, 44 insertions, 37 deletions
diff --git a/spec/lib/gitlab/gitaly_client/commit_spec.rb b/spec/lib/gitlab/gitaly_client/commit_spec.rb index cf1bc74779e..dff5b25c712 100644 --- a/spec/lib/gitlab/gitaly_client/commit_spec.rb +++ b/spec/lib/gitlab/gitaly_client/commit_spec.rb @@ -16,7 +16,7 @@ describe Gitlab::GitalyClient::Commit do right_commit_id: commit.id ) - expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_diff).with(request) + expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_diff).with(request, kind_of(Hash)) described_class.new(repository).diff_from_parent(commit) end @@ -31,7 +31,7 @@ describe Gitlab::GitalyClient::Commit do right_commit_id: initial_commit.id ) - expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_diff).with(request) + expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_diff).with(request, kind_of(Hash)) described_class.new(repository).diff_from_parent(initial_commit) end @@ -61,7 +61,7 @@ describe Gitlab::GitalyClient::Commit do right_commit_id: commit.id ) - expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_delta).with(request).and_return([]) + expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_delta).with(request, kind_of(Hash)).and_return([]) described_class.new(repository).commit_deltas(commit) end @@ -76,7 +76,7 @@ describe Gitlab::GitalyClient::Commit do right_commit_id: initial_commit.id ) - expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_delta).with(request).and_return([]) + expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_delta).with(request, kind_of(Hash)).and_return([]) described_class.new(repository).commit_deltas(initial_commit) end diff --git a/spec/lib/gitlab/gitaly_client/notifications_spec.rb b/spec/lib/gitlab/gitaly_client/notifications_spec.rb index e5c9e06a15e..7404ffe0f06 100644 --- a/spec/lib/gitlab/gitaly_client/notifications_spec.rb +++ b/spec/lib/gitlab/gitaly_client/notifications_spec.rb @@ -8,8 +8,8 @@ describe Gitlab::GitalyClient::Notifications do subject { described_class.new(project.repository) } it 'sends a post_receive message' do - expect_any_instance_of(Gitaly::Notifications::Stub). - to receive(:post_receive).with(gitaly_request_with_path(storage_name, relative_path)) + expect_any_instance_of(Gitaly::Notifications::Stub) + .to receive(:post_receive).with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) subject.post_receive end diff --git a/spec/lib/gitlab/gitaly_client/ref_spec.rb b/spec/lib/gitlab/gitaly_client/ref_spec.rb index 2ea44ef74b0..7c090460764 100644 --- a/spec/lib/gitlab/gitaly_client/ref_spec.rb +++ b/spec/lib/gitlab/gitaly_client/ref_spec.rb @@ -6,23 +6,12 @@ describe Gitlab::GitalyClient::Ref do let(:relative_path) { project.path_with_namespace + '.git' } let(:client) { described_class.new(project.repository) } - before do - allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true) - end - - after do - # When we say `expect_any_instance_of(Gitaly::Ref::Stub)` a double is created, - # and because GitalyClient shares stubs these will get passed from example to - # example, which will cause an error, so we clean the stubs after each example. - Gitlab::GitalyClient.clear_stubs! - end - describe '#branch_names' do it 'sends a find_all_branch_names message' do - expect_any_instance_of(Gitaly::Ref::Stub). - to receive(:find_all_branch_names). - with(gitaly_request_with_path(storage_name, relative_path)). - and_return([]) + 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([]) client.branch_names end @@ -30,10 +19,10 @@ describe Gitlab::GitalyClient::Ref do describe '#tag_names' do it 'sends a find_all_tag_names message' do - expect_any_instance_of(Gitaly::Ref::Stub). - to receive(:find_all_tag_names). - with(gitaly_request_with_path(storage_name, relative_path)). - and_return([]) + 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([]) client.tag_names end @@ -41,10 +30,10 @@ describe Gitlab::GitalyClient::Ref do describe '#default_branch_name' do it 'sends a find_default_branch_name message' do - expect_any_instance_of(Gitaly::Ref::Stub). - to receive(:find_default_branch_name). - with(gitaly_request_with_path(storage_name, relative_path)). - and_return(double(name: 'foo')) + 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')) client.default_branch_name end @@ -52,25 +41,43 @@ describe Gitlab::GitalyClient::Ref do describe '#local_branches' do it 'sends a find_local_branches message' do - expect_any_instance_of(Gitaly::Ref::Stub). - to receive(:find_local_branches). - with(gitaly_request_with_path(storage_name, relative_path)). - and_return([]) + 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([]) client.local_branches end it 'parses and sends the sort parameter' do - expect_any_instance_of(Gitaly::Ref::Stub). - to receive(:find_local_branches). - with(gitaly_request_with_params(sort_by: :UPDATED_DESC)). - and_return([]) + 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([]) client.local_branches(sort_by: 'updated_desc') end + 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 + 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 + + 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') } + + it { is_expected.to be_utf8 } + it { is_expected.to eq('refs/heads/master') } + end end |