Extract EE specific files/lines for some discussion tests

We have the following files containing EE specific code. We should move them to ee/

spec/presenters/merge_request_presenter_spec.rb
diff --git a/spec/presenters/merge_request_presenter_spec.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/presenters/merge_request_presenter_spec.rb
index bafcddebbb7..0ae7008f6a1 100644
--- a/spec/presenters/merge_request_presenter_spec.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/presenters/merge_request_presenter_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
 
 describe MergeRequestPresenter do
   let(:resource) { create :merge_request, source_project: project }
-  let(:project) { create :project }
+  let(:project) { create(:project, :repository) }
   let(:user) { create(:user) }
 
   describe '#ci_status' do
@@ -392,6 +392,111 @@ describe MergeRequestPresenter do
     end
   end
 
+  describe '#can_push_to_source_branch' do
+    before do
+      allow(resource).to receive(:source_branch_exists?) { source_branch_exists }
+
+      allow_any_instance_of(Gitlab::UserAccess::RequestCacheExtension)
+        .to receive(:can_push_to_branch?)
+        .with(resource.source_branch)
+        .and_return(can_push_to_branch)
+    end
+
+    subject do
+      described_class.new(resource, current_user: user).can_push_to_source_branch?
+    end
+
+    context 'when source branch exists AND user can push to source branch' do
+      let(:source_branch_exists) { true }
+      let(:can_push_to_branch) { true }
+
+      it 'returns true' do
+        is_expected.to eq(true)
+      end
+    end
+
+    context 'when source branch does not exists' do
+      let(:source_branch_exists) { false }
+      let(:can_push_to_branch) { true }
+
+      it 'returns false' do
+        is_expected.to eq(false)
+      end
+    end
+
+    context 'when user cannot push to source branch' do
+      let(:source_branch_exists) { true }
+      let(:can_push_to_branch) { false }
+
+      it 'returns false' do
+        is_expected.to eq(false)
+      end
+    end
+  end
+
+  describe '#rebase_path' do
+    before do
+      allow(resource).to receive(:rebase_in_progress?) { rebase_in_progress }
+      allow(resource).to receive(:should_be_rebased?) { should_be_rebased }
+
+      allow_any_instance_of(Gitlab::UserAccess::RequestCacheExtension)
+        .to receive(:can_push_to_branch?)
+        .with(resource.source_branch)
+        .and_return(can_push_to_branch)
+    end
+
+    subject do
+      described_class.new(resource, current_user: user).rebase_path
+    end
+
+    context 'when can rebase' do
+      let(:rebase_in_progress) { false }
+      let(:can_push_to_branch) { true }
+      let(:should_be_rebased) { true }
+
+      before do
+        allow(resource).to receive(:source_branch_exists?) { true }
+      end
+
+      it 'returns path' do
+        is_expected
+          .to eq("/#{project.full_path}/merge_requests/#{resource.iid}/rebase")
+      end
+    end
+
+    context 'when cannot rebase' do
+      context 'when rebase in progress' do
+        let(:rebase_in_progress) { true }
+        let(:can_push_to_branch) { true }
+        let(:should_be_rebased) { true }
+
+        it 'returns nil' do
+          is_expected.to be_nil
+        end
+      end
+
+      context 'when user cannot merge' do
+        let(:rebase_in_progress) { false }
+        let(:can_push_to_branch) { false }
+        let(:should_be_rebased) { true }
+
+        it 'returns nil' do
+          is_expected.to be_nil
+        end
+      end
+
+      context 'should not be rebased' do
+        let(:rebase_in_progress) { false }
+        let(:can_push_to_branch) { true }
+        let(:should_be_rebased) { false }
+
+        it 'returns nil' do
+          is_expected.to be_nil
+        end
+      end
+    end
+  end
+
   describe '#source_branch_with_namespace_link' do
     subject do
       described_class.new(resource, current_user: user).source_branch_with_namespace_link
spec/services/boards/issues/create_service_spec.rb
diff --git a/spec/services/boards/issues/create_service_spec.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/services/boards/issues/create_service_spec.rb
index f0179e35652..c16d0d2a6b1 100644
--- a/spec/services/boards/issues/create_service_spec.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/services/boards/issues/create_service_spec.rb
@@ -29,5 +29,23 @@ describe Boards::Issues::CreateService do
 
       expect(issue.labels).to eq [label]
     end
+
+    it 'adds the board assignee, weight, labels and milestone to the issue' do
+      board_assignee = create(:user)
+      project.add_developer(board_assignee)
+      board_milestone = create(:milestone, project: project)
+      board_label = create(:label, project: project)
+      board.update!(assignee: board_assignee,
+                    milestone: board_milestone,
+                    label_ids: [board_label.id],
+                    weight: 4)
+
+      issue = service.execute
+
+      expect(issue.assignees).to eq([board_assignee])
+      expect(issue.weight).to eq(board.weight)
+      expect(issue.milestone).to eq(board_milestone)
+      expect(issue.labels).to contain_exactly(label, board_label)
+    end
   end
 end
spec/services/issues/move_service_spec.rb
diff --git a/spec/services/issues/move_service_spec.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/services/issues/move_service_spec.rb
index 1e088bc7d9b..5da4a638be1 100644
--- a/spec/services/issues/move_service_spec.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/services/issues/move_service_spec.rb
@@ -138,6 +138,20 @@ describe Issues::MoveService do
             .not_to raise_error # Sidekiq::Worker::EnqueueFromTransactionError
         end
       end
+
+      context 'group issue hooks' do
+        let!(:hook) { create(:group_hook, group: new_project.group, issues_events: true) }
+
+        it 'executes group issue hooks' do
+          allow_any_instance_of(WebHookService).to receive(:execute)
+
+          # Ideally, we'd test that `WebHookWorker.jobs.size` increased by 1,
+          # but since the entire spec run takes place in a transaction, we never
+          # actually get to the `after_commit` hook that queues these jobs.
+          expect { move_service.execute(old_issue, new_project) }
+            .not_to raise_error # Sidekiq::Worker::EnqueueFromTransactionError
+        end
+      end
     end
 
     describe 'move permissions' do

Looks like they're EE only tests and we could just move to the EE spec files.

Edited Feb 26, 2019 by Yorick Peterse
Assignee Loading
Time tracking Loading