diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 21:09:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 21:09:25 +0300 |
commit | 967812838c7e7742729a4c7aeb9859f98a509622 (patch) | |
tree | 22db2e6642be51cb12535db7863331457e5523c3 /spec/models/project_services | |
parent | 074d013e1eb3f6e0c27f96a3be8b9361254c8a98 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/project_services')
-rw-r--r-- | spec/models/project_services/teamcity_service_spec.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/spec/models/project_services/teamcity_service_spec.rb b/spec/models/project_services/teamcity_service_spec.rb index 3d875bc49e7..0dd77b68588 100644 --- a/spec/models/project_services/teamcity_service_spec.rb +++ b/spec/models/project_services/teamcity_service_spec.rb @@ -7,6 +7,7 @@ describe TeamcityService, :use_clean_rails_memory_store_caching do include StubRequests let(:teamcity_url) { 'http://gitlab.com/teamcity' } + let(:teamcity_full_url) { 'http://gitlab.com/teamcity/httpAuth/app/rest/builds/branch:unspecified:any,revision:123' } let(:project) { create(:project) } subject(:service) do @@ -165,6 +166,16 @@ describe TeamcityService, :use_clean_rails_memory_store_caching do is_expected.to eq('http://gitlab.com/teamcity/viewLog.html?buildId=666&buildTypeId=foo') end end + + it 'returns the teamcity_url when teamcity is unreachable' do + stub_full_request(teamcity_full_url).to_raise(Errno::ECONNREFUSED) + + expect(Gitlab::ErrorTracking) + .to receive(:log_exception) + .with(instance_of(Errno::ECONNREFUSED), project_id: project.id) + + is_expected.to eq(teamcity_url) + end end context 'commit_status' do @@ -205,6 +216,16 @@ describe TeamcityService, :use_clean_rails_memory_store_caching do is_expected.to eq(:error) end + + it 'sets commit status to :error when teamcity is unreachable' do + stub_full_request(teamcity_full_url).to_raise(Errno::ECONNREFUSED) + + expect(Gitlab::ErrorTracking) + .to receive(:log_exception) + .with(instance_of(Errno::ECONNREFUSED), project_id: project.id) + + is_expected.to eq(:error) + end end end @@ -300,7 +321,6 @@ describe TeamcityService, :use_clean_rails_memory_store_caching do end def stub_request(status: 200, body: nil, build_status: 'success') - teamcity_full_url = 'http://gitlab.com/teamcity/httpAuth/app/rest/builds/branch:unspecified:any,revision:123' auth = %w(mic password) body ||= %Q({"build":{"status":"#{build_status}","id":"666"}}) |