2014-09-02 18:07:02 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
describe MergeRequests::CreateService, services: true do
|
2014-09-02 18:07:02 +05:30
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
describe :execute do
|
2015-04-26 12:48:37 +05:30
|
|
|
context 'valid params' do
|
|
|
|
let(:opts) do
|
|
|
|
{
|
2014-09-02 18:07:02 +05:30
|
|
|
title: 'Awesome merge_request',
|
|
|
|
description: 'please fix',
|
2015-09-25 12:07:36 +05:30
|
|
|
source_branch: 'feature',
|
2014-09-02 18:07:02 +05:30
|
|
|
target_branch: 'master'
|
|
|
|
}
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
let(:service) { MergeRequests::CreateService.new(project, user, opts) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.team << [user, :master]
|
|
|
|
allow(service).to receive(:execute_hooks)
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
@merge_request = service.execute
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
it { expect(@merge_request).to be_valid }
|
|
|
|
it { expect(@merge_request.title).to eq('Awesome merge_request') }
|
|
|
|
|
|
|
|
it 'should execute hooks with default action' do
|
|
|
|
expect(service).to have_received(:execute_hooks).with(@merge_request)
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|