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

39 lines
1 KiB
Ruby
Raw Normal View History

2015-09-25 12:07:36 +05:30
require 'spec_helper'
describe Ci::CreateTriggerRequestService do
let(:service) { Ci::CreateTriggerRequestService.new }
2015-10-24 18:46:33 +05:30
let(:gl_project) { create(:project) }
let(:project) { create(:ci_project, gl_project: gl_project) }
let(:trigger) { create(:ci_trigger, project: project) }
before do
stub_ci_commit_to_return_yaml_file
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
2015-10-24 18:46:33 +05:30
stub_ci_commit_yaml_file('{}')
FactoryGirl.create :ci_commit, gl_project: gl_project
2015-09-25 12:07:36 +05:30
end
it { expect(subject).to be_nil }
end
end
end