diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-01 03:06:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-01 03:06:42 +0300 |
commit | b38cf7ccdf8b7ca90bce587a1bf4765631733017 (patch) | |
tree | 37b157087207cae5ec7b9e028864e859705c07d6 /spec | |
parent | 08f4ce10c04d705148a7e14556443b9e3aee6821 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/health_controller_spec.rb | 13 | ||||
-rw-r--r-- | spec/controllers/projects/branches_controller_spec.rb | 50 |
2 files changed, 61 insertions, 2 deletions
diff --git a/spec/controllers/health_controller_spec.rb b/spec/controllers/health_controller_spec.rb index 8c44ae4e3de..ae05573af2e 100644 --- a/spec/controllers/health_controller_spec.rb +++ b/spec/controllers/health_controller_spec.rb @@ -30,6 +30,19 @@ describe HealthController do expect(json_response['shared_state_check']['status']).to eq('ok') expect(json_response['gitaly_check']['status']).to eq('ok') end + + it 'responds with readiness checks data when a failure happens' do + allow(Gitlab::HealthChecks::Redis::RedisCheck).to receive(:readiness).and_return(Gitlab::HealthChecks::Result.new(false, "check error")) + + subject + + expect(json_response['redis_check']['status']).to eq('failed') + expect(json_response['redis_check']['message']).to eq('check error') + expect(json_response['cache_check']['status']).to eq('ok') + + expect(response.status).to eq(503) + expect(response.headers['X-GitLab-Custom-Error']).to eq(1) + end end context 'accessed from whitelisted ip' do diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb index f5bcea4a097..affe0e0f970 100644 --- a/spec/controllers/projects/branches_controller_spec.rb +++ b/spec/controllers/projects/branches_controller_spec.rb @@ -578,7 +578,9 @@ describe Projects::BranchesController do describe 'GET diverging_commit_counts' do before do sign_in(user) + end + it 'returns the commit counts behind and ahead of default branch' do get :diverging_commit_counts, format: :json, params: { @@ -586,14 +588,58 @@ describe Projects::BranchesController do project_id: project, names: ['fix', 'add-pdf-file', 'branch-merged'] } - end - it 'returns the commit counts behind and ahead of default branch' do + expect(response).to have_gitlab_http_status(200) expect(json_response).to eq( "fix" => { "behind" => 29, "ahead" => 2 }, "branch-merged" => { "behind" => 1, "ahead" => 0 }, "add-pdf-file" => { "behind" => 0, "ahead" => 3 } ) end + + it 'returns the commits counts with no names provided' do + allow_any_instance_of(Repository).to receive(:branch_count).and_return(Kaminari.config.default_per_page) + + get :diverging_commit_counts, + format: :json, + params: { + namespace_id: project.namespace, + project_id: project + } + + expect(response).to have_gitlab_http_status(200) + expect(json_response.count).to be > 1 + end + + describe 'with many branches' do + before do + allow_any_instance_of(Repository).to receive(:branch_count).and_return(Kaminari.config.default_per_page + 1) + end + + it 'returns 422 if no names are specified' do + get :diverging_commit_counts, + format: :json, + params: { + namespace_id: project.namespace, + project_id: project + } + + expect(response).to have_gitlab_http_status(422) + expect(json_response['error']).to eq("Specify at least one and at most #{Kaminari.config.default_per_page} branch names") + end + + it 'returns the list of counts' do + get :diverging_commit_counts, + format: :json, + params: { + namespace_id: project.namespace, + project_id: project, + names: ['fix', 'add-pdf-file', 'branch-merged'] + } + + expect(response).to have_gitlab_http_status(200) + expect(json_response.count).to be > 1 + end + end end end |