diff options
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 24 | ||||
-rw-r--r-- | spec/models/project_services/bamboo_service_spec.rb | 17 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 38 |
3 files changed, 54 insertions, 25 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index c3f2e3aebdd..425194ba0e3 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -3061,20 +3061,6 @@ describe Ci::Pipeline, :mailer do expect(pipeline.source_bridge).to eq bridge end end - - describe '#update_bridge_status!' do - it 'can update bridge status if it is running' do - pipeline.update_bridge_status! - - expect(bridge.reload).to be_success - end - - it 'can not update bridge status if is not active' do - bridge.success! - - expect { pipeline.update_bridge_status! }.not_to change { bridge.status } - end - end end context 'when an upstream status is a build' do @@ -3101,16 +3087,6 @@ describe Ci::Pipeline, :mailer do expect(pipeline.source_bridge).to be_nil end end - - describe '#update_bridge_status!' do - it 'tracks an ArgumentError and does not update upstream job status' do - expect(Gitlab::ErrorTracking) - .to receive(:track_exception) - .with(instance_of(ArgumentError), pipeline_id: pipeline.id) - - pipeline.update_bridge_status! - end - end end end end diff --git a/spec/models/project_services/bamboo_service_spec.rb b/spec/models/project_services/bamboo_service_spec.rb index 1b946278790..c1efa3a4348 100644 --- a/spec/models/project_services/bamboo_service_spec.rb +++ b/spec/models/project_services/bamboo_service_spec.rb @@ -8,9 +8,11 @@ describe BambooService, :use_clean_rails_memory_store_caching do let(:bamboo_url) { 'http://gitlab.com/bamboo' } + let_it_be(:project) { create(:project) } + subject(:service) do described_class.create( - project: create(:project), + project: project, properties: { bamboo_url: bamboo_url, username: 'mic', @@ -224,6 +226,19 @@ describe BambooService, :use_clean_rails_memory_store_caching do is_expected.to eq(:error) end + + Gitlab::HTTP::HTTP_ERRORS.each do |http_error| + it "sets commit status to :error with a #{http_error.name} error" do + WebMock.stub_request(:get, 'http://gitlab.com/bamboo/rest/api/latest/result/byChangeset/123?os_authType=basic') + .to_raise(http_error) + + expect(Gitlab::ErrorTracking) + .to receive(:log_exception) + .with(instance_of(http_error), project_id: project.id) + + is_expected.to eq(:error) + end + end end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 51fcee29485..694c6935c1d 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -2282,6 +2282,44 @@ describe Project do end end + describe '#jira_import_status' do + let(:project) { create(:project, :import_started, import_type: 'jira') } + + context 'when import_data is nil' do + it 'returns none' do + expect(project.import_data).to be nil + expect(project.jira_import_status).to eq('none') + end + end + + context 'when import_data is set' do + let(:jira_import_data) { JiraImportData.new } + let(:project) { create(:project, :import_started, import_data: jira_import_data, import_type: 'jira') } + + it 'returns none' do + expect(project.import_data.becomes(JiraImportData).force_import?).to be false + expect(project.jira_import_status).to eq('none') + end + + context 'when jira_force_import is true' do + let(:imported_jira_project) do + JiraImportData::JiraProjectDetails.new('xx', Time.now.strftime('%Y-%m-%d %H:%M:%S'), { user_id: 1, name: 'root' }) + end + + before do + jira_import_data = project.import_data.becomes(JiraImportData) + jira_import_data << imported_jira_project + jira_import_data.force_import! + end + + it 'returns started' do + expect(project.import_data.becomes(JiraImportData).force_import?).to be true + expect(project.jira_import_status).to eq('started') + end + end + end + end + describe '#human_import_status_name' do context 'with import_state' do it 'returns the right human import status' do |