debian-mirror-gitlab/spec/workers/create_pipeline_worker_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.4 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
2023-05-27 22:25:52 +05:30
RSpec.describe CreatePipelineWorker, feature_category: :continuous_integration do
2018-03-17 18:26:18 +05:30
describe '#perform' do
let(:worker) { described_class.new }
context 'when a project not found' do
it 'does not call the Service' do
expect(Ci::CreatePipelineService).not_to receive(:new)
2020-11-24 15:15:51 +05:30
expect { worker.perform(non_existing_record_id, create(:user).id, 'master', :web) }.to raise_error(ActiveRecord::RecordNotFound)
2018-03-17 18:26:18 +05:30
end
end
context 'when a user not found' do
let(:project) { create(:project) }
it 'does not call the Service' do
expect(Ci::CreatePipelineService).not_to receive(:new)
2020-11-24 15:15:51 +05:30
expect { worker.perform(project.id, non_existing_record_id, project.default_branch, :web) }.to raise_error(ActiveRecord::RecordNotFound)
2018-03-17 18:26:18 +05:30
end
end
context 'when everything is ok' do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:create_pipeline_service) { instance_double(Ci::CreatePipelineService) }
it 'calls the Service' do
expect(Ci::CreatePipelineService).to receive(:new).with(project, user, ref: project.default_branch).and_return(create_pipeline_service)
expect(create_pipeline_service).to receive(:execute).with(:web, any_args)
worker.perform(project.id, user.id, project.default_branch, :web)
end
end
end
end