2014-04-03 11:16:05 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe MergeRequests::CreateService do
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
describe :execute do
|
2015-01-17 19:34:34 -05:00
|
|
|
context 'valid params' do
|
|
|
|
let(:opts) do
|
|
|
|
{
|
2014-04-03 11:16:05 -04:00
|
|
|
title: 'Awesome merge_request',
|
|
|
|
description: 'please fix',
|
2015-08-11 08:33:31 -04:00
|
|
|
source_branch: 'feature',
|
2014-04-03 11:16:05 -04:00
|
|
|
target_branch: 'master'
|
|
|
|
}
|
2015-01-17 19:34:34 -05:00
|
|
|
end
|
|
|
|
let(:service) { MergeRequests::CreateService.new(project, user, opts) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.team << [user, :master]
|
2015-02-12 13:17:35 -05:00
|
|
|
allow(service).to receive(:execute_hooks)
|
2014-04-03 11:16:05 -04:00
|
|
|
|
2015-01-17 19:34:34 -05:00
|
|
|
@merge_request = service.execute
|
2014-04-03 11:16:05 -04:00
|
|
|
end
|
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { expect(@merge_request).to be_valid }
|
|
|
|
it { expect(@merge_request.title).to eq('Awesome merge_request') }
|
2015-01-17 19:34:34 -05:00
|
|
|
|
|
|
|
it 'should execute hooks with default action' do
|
|
|
|
expect(service).to have_received(:execute_hooks).with(@merge_request)
|
|
|
|
end
|
2014-04-03 11:16:05 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|