Commit 81b1fd6f authored by Sean McGivern's avatar Sean McGivern

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
parents 3bd4016b 3b2da850
...@@ -18,6 +18,11 @@ FactoryBot.define do ...@@ -18,6 +18,11 @@ FactoryBot.define do
state "closed" state "closed"
end 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| after(:build, :stub) do |milestone, evaluator|
if evaluator.group if evaluator.group
milestone.group = evaluator.group milestone.group = evaluator.group
......
# 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
...@@ -145,7 +145,9 @@ describe Notes::CreateService do ...@@ -145,7 +145,9 @@ describe Notes::CreateService do
let(:note_text) { %(HELLO\n/close\n/assign @#{user.username}\nWORLD) } let(:note_text) { %(HELLO\n/close\n/assign @#{user.username}\nWORLD) }
it 'saves the note and does not alter the note text' do 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 note = described_class.new(project, user, opts.merge(note: note_text)).execute
......
...@@ -4,7 +4,9 @@ shared_examples 'issues move service' do |group| ...@@ -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 } } 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 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) described_class.new(parent, user, params).execute(issue)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment