summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-08-08 10:39:02 +0000
committerSean McGivern <sean@mcgivern.me.uk>2018-08-08 10:39:02 +0000
commit81b1fd6f7a92744b67570706203cd0d2cd9ee923 (patch)
tree8f09af9787b976007f985b69a5d8d44780174e78
parent3bd4016b96fc4cb6a3c1dc5324ea0bfd12ee1ea1 (diff)
parent3b2da85073c29b78f328275db00fbba590eb4f9d (diff)
downloadgitlab-ce-81b1fd6f7a92744b67570706203cd0d2cd9ee923.tar.gz
Merge branch 'ee-6470-milestone-dates-integrated-into-epics' into 'master'
CE port of "Add date fields to Epic to enable dates to source from milestones" See merge request gitlab-org/gitlab-ce!20687
-rw-r--r--spec/factories/milestones.rb5
-rw-r--r--spec/services/milestones/update_service_spec.rb41
-rw-r--r--spec/services/notes/create_service_spec.rb4
-rw-r--r--spec/support/shared_examples/services/boards/issues_move_service.rb4
4 files changed, 52 insertions, 2 deletions
diff --git a/spec/factories/milestones.rb b/spec/factories/milestones.rb
index f95632e7187..019e4420212 100644
--- a/spec/factories/milestones.rb
+++ b/spec/factories/milestones.rb
@@ -18,6 +18,11 @@ FactoryBot.define do
state "closed"
end
+ trait :with_dates do
+ start_date { Date.new(2000, 1, 1) }
+ due_date { Date.new(2000, 1, 30) }
+ end
+
after(:build, :stub) do |milestone, evaluator|
if evaluator.group
milestone.group = evaluator.group
diff --git a/spec/services/milestones/update_service_spec.rb b/spec/services/milestones/update_service_spec.rb
new file mode 100644
index 00000000000..3b91442c0ba
--- /dev/null
+++ b/spec/services/milestones/update_service_spec.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+require 'spec_helper'
+
+describe Milestones::UpdateService do
+ let(:project) { create(:project) }
+ let(:user) { build(:user) }
+ let(:milestone) { create(:milestone, project: project) }
+
+ describe '#execute' do
+ context "valid params" do
+ let(:inner_service) { double(:service) }
+
+ before do
+ project.add_maintainer(user)
+ end
+
+ subject { described_class.new(project, user, { title: 'new_title' }).execute(milestone) }
+
+ it { expect(subject).to be_valid }
+ it { expect(subject.title).to eq('new_title') }
+
+ context 'state_event is activate' do
+ it 'calls ReopenService' do
+ expect(Milestones::ReopenService).to receive(:new).with(project, user, {}).and_return(inner_service)
+ expect(inner_service).to receive(:execute).with(milestone)
+
+ described_class.new(project, user, { state_event: 'activate' }).execute(milestone)
+ end
+ end
+
+ context 'state_event is close' do
+ it 'calls ReopenService' do
+ expect(Milestones::CloseService).to receive(:new).with(project, user, {}).and_return(inner_service)
+ expect(inner_service).to receive(:execute).with(milestone)
+
+ described_class.new(project, user, { state_event: 'close' }).execute(milestone)
+ end
+ end
+ end
+ end
+end
diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb
index 0fd37c95e42..b1290fd0d47 100644
--- a/spec/services/notes/create_service_spec.rb
+++ b/spec/services/notes/create_service_spec.rb
@@ -145,7 +145,9 @@ describe Notes::CreateService do
let(:note_text) { %(HELLO\n/close\n/assign @#{user.username}\nWORLD) }
it 'saves the note and does not alter the note text' do
- expect_any_instance_of(Issues::UpdateService).to receive(:execute).and_call_original
+ service = double(:service)
+ allow(Issues::UpdateService).to receive(:new).and_return(service)
+ expect(service).to receive(:execute)
note = described_class.new(project, user, opts.merge(note: note_text)).execute
diff --git a/spec/support/shared_examples/services/boards/issues_move_service.rb b/spec/support/shared_examples/services/boards/issues_move_service.rb
index 737863ea411..6d29a97c56d 100644
--- a/spec/support/shared_examples/services/boards/issues_move_service.rb
+++ b/spec/support/shared_examples/services/boards/issues_move_service.rb
@@ -4,7 +4,9 @@ shared_examples 'issues move service' do |group|
let(:params) { { board_id: board1.id, from_list_id: list1.id, to_list_id: list2.id } }
it 'delegates the label changes to Issues::UpdateService' do
- expect_any_instance_of(Issues::UpdateService).to receive(:execute).with(issue).once
+ service = double(:service)
+ expect(Issues::UpdateService).to receive(:new).and_return(service)
+ expect(service).to receive(:execute).with(issue).once
described_class.new(parent, user, params).execute(issue)
end