debian-mirror-gitlab/spec/services/ci/create_trigger_request_service_spec.rb

38 lines
983 B
Ruby
Raw Normal View History

2015-09-25 12:07:36 +05:30
require 'spec_helper'
2015-12-23 02:04:40 +05:30
describe Ci::CreateTriggerRequestService, services: true do
2015-09-25 12:07:36 +05:30
let(:service) { Ci::CreateTriggerRequestService.new }
2015-12-23 02:04:40 +05:30
let(:project) { create(:project) }
2015-10-24 18:46:33 +05:30
let(:trigger) { create(:ci_trigger, project: project) }
before do
stub_ci_pipeline_to_return_yaml_file
2015-10-24 18:46:33 +05:30
end
2015-09-25 12:07:36 +05:30
describe :execute do
context 'valid params' do
subject { service.execute(project, trigger, 'master') }
it { expect(subject).to be_kind_of(Ci::TriggerRequest) }
2015-10-24 18:46:33 +05:30
it { expect(subject.builds.first).to be_kind_of(Ci::Build) }
2015-09-25 12:07:36 +05:30
end
context 'no commit for ref' do
subject { service.execute(project, trigger, 'other-branch') }
it { expect(subject).to be_nil }
end
context 'no builds created' do
subject { service.execute(project, trigger, 'master') }
before do
stub_ci_pipeline_yaml_file('{}')
FactoryGirl.create :ci_pipeline, project: project
2015-09-25 12:07:36 +05:30
end
it { expect(subject).to be_nil }
end
end
end