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

38 lines
977 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_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('{}')
2015-12-23 02:04:40 +05:30
FactoryGirl.create :ci_commit, project: project
2015-09-25 12:07:36 +05:30
end
it { expect(subject).to be_nil }
end
end
end