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
|
2015-09-15 09:42:02 -04:00
|
|
|
let(:service) { Ci::CreateTriggerRequestService.new }
|
2015-12-04 06:55:23 -05:00
|
|
|
let(:project) { create(:project) }
|
2015-10-05 10:21:18 -04:00
|
|
|
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
|
2016-06-03 10:22:26 -04:00
|
|
|
stub_ci_pipeline_to_return_yaml_file
|
2015-10-05 07:37:50 -04:00
|
|
|
end
|
|
|
|
|
2015-08-25 21:42:46 -04:00
|
|
|
describe :execute do
|
|
|
|
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) }
|
2015-10-05 10:21:18 -04:00
|
|
|
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
|
2016-06-03 10:22:26 -04:00
|
|
|
stub_ci_pipeline_yaml_file('{}')
|
|
|
|
FactoryGirl.create :ci_pipeline, project: project
|
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
|