diff options
Diffstat (limited to 'spec/workers/projects')
-rw-r--r-- | spec/workers/projects/after_import_worker_spec.rb | 2 | ||||
-rw-r--r-- | spec/workers/projects/post_creation_worker_spec.rb | 34 |
2 files changed, 34 insertions, 2 deletions
diff --git a/spec/workers/projects/after_import_worker_spec.rb b/spec/workers/projects/after_import_worker_spec.rb index a14b2443173..85d15c89b0a 100644 --- a/spec/workers/projects/after_import_worker_spec.rb +++ b/spec/workers/projects/after_import_worker_spec.rb @@ -3,8 +3,6 @@ require 'spec_helper' RSpec.describe Projects::AfterImportWorker do - include GitHelpers - subject { worker.perform(project.id) } let(:worker) { described_class.new } diff --git a/spec/workers/projects/post_creation_worker_spec.rb b/spec/workers/projects/post_creation_worker_spec.rb index 3158ac9fa27..732dc540fb7 100644 --- a/spec/workers/projects/post_creation_worker_spec.rb +++ b/spec/workers/projects/post_creation_worker_spec.rb @@ -81,6 +81,40 @@ RSpec.describe Projects::PostCreationWorker do end end end + + describe 'Incident timeline event tags' do + context 'when project is nil' do + let(:job_args) { [nil] } + + it 'does not create event tags' do + expect { subject }.not_to change { IncidentManagement::TimelineEventTag.count } + end + end + + context 'when project is created', :aggregate_failures do + it 'creates tags for the project' do + expect { subject }.to change { IncidentManagement::TimelineEventTag.count }.by(2) + + expect(project.incident_management_timeline_event_tags.pluck_names).to match_array( + [ + ::IncidentManagement::TimelineEventTag::START_TIME_TAG_NAME, + ::IncidentManagement::TimelineEventTag::END_TIME_TAG_NAME + ] + ) + end + + it 'raises error if record creation fails' do + allow_next_instance_of(IncidentManagement::TimelineEventTag) do |tag| + allow(tag).to receive(:valid?).and_return(false) + end + + expect(Gitlab::ErrorTracking).to receive(:track_exception).with(an_instance_of(ActiveRecord::RecordInvalid), include(extra: { project_id: a_kind_of(Integer) })).twice + subject + + expect(project.incident_management_timeline_event_tags).to be_empty + end + end + end end end end |