tests for inheriting milestones and labels

This commit is contained in:
haseeb 2017-08-11 00:14:15 +05:30
parent a115267e25
commit 59d7ffad06

View file

@ -4,8 +4,21 @@ describe MergeRequests::CreateFromIssueService do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:issue) { create(:issue, project: project) }
let(:milestone) { create(:milestone, project: project) }
let(:labels) { create_pair(:label, project: project) }
subject(:service) { described_class.new(project, user, issue_iid: issue.iid) }
subject(:service2) do
described_class.new(
project,
user,
{
issue_iid: issue.iid,
milestone_id: milestone.id,
label_ids: labels.map(&:id)
}
)
end
before do
project.add_developer(user)
@ -25,6 +38,18 @@ describe MergeRequests::CreateFromIssueService do
described_class.new(project, user, issue_iid: -1).execute
end
it "can inherit labels" do
result = service2.execute
expect(result[:merge_request].label_ids).to eq(labels.map(&:id))
end
it "can inherit milestones" do
result = service2.execute
expect(result[:merge_request].milestone_id).to eq(milestone.id)
end
it 'delegates the branch creation to CreateBranchService' do
expect_any_instance_of(CreateBranchService).to receive(:execute).once.and_call_original