gitlab-org--gitlab-foss/spec/services/ci/create_trigger_request_service_spec.rb

37 lines
957 B
Ruby
Raw Normal View History

2015-08-25 21:42:46 -04:00
require 'spec_helper'
2015-12-09 05:55:49 -05:00
describe Ci::CreateTriggerRequestService, services: true do
let(:service) { described_class.new }
2015-12-04 06:55:23 -05:00
let(:project) { create(:project) }
let(:trigger) { create(:ci_trigger, project: project) }
2015-08-25 21:42:46 -04:00
2015-10-05 07:37:50 -04:00
before do
stub_ci_pipeline_to_return_yaml_file
2015-10-05 07:37:50 -04:00
end
2016-07-11 18:12:31 -04:00
describe '#execute' do
2015-08-25 21:42:46 -04:00
context 'valid params' do
subject { service.execute(project, trigger, 'master') }
2015-09-15 09:42:02 -04:00
it { expect(subject).to be_kind_of(Ci::TriggerRequest) }
it { expect(subject.builds.first).to be_kind_of(Ci::Build) }
2015-08-25 21:42:46 -04:00
end
context 'no commit for ref' do
subject { service.execute(project, trigger, 'other-branch') }
2015-09-15 09:00:45 -04:00
it { expect(subject).to be_nil }
2015-08-25 21:42:46 -04:00
end
context 'no builds created' do
subject { service.execute(project, trigger, 'master') }
before do
stub_ci_pipeline_yaml_file('script: { only: [develop], script: hello World }')
2015-08-25 21:42:46 -04:00
end
2015-09-15 09:00:45 -04:00
it { expect(subject).to be_nil }
2015-08-25 21:42:46 -04:00
end
end
end