From 59d7ffad06828435e31c7ea09c97c4b79909ef77 Mon Sep 17 00:00:00 2001
From: haseeb <haseebeqx@yahoo.com>
Date: Fri, 11 Aug 2017 00:14:15 +0530
Subject: [PATCH] tests for inheriting milestones and labels

---
 spec/services/merge_requests/create_from_issue_service_spec.rb | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/spec/services/merge_requests/create_from_issue_service_spec.rb b/spec/services/merge_requests/create_from_issue_service_spec.rb
index 492b55c..bdc53c7 100644
--- a/spec/services/merge_requests/create_from_issue_service_spec.rb
+++ b/spec/services/merge_requests/create_from_issue_service_spec.rb
@@ -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
 
--
libgit2 0.27.1