blob: ac17915c15afa5a5444af55c40f5252e28a6085b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# frozen_string_literal: true
RSpec.shared_examples "setting work item's milestone" do
context "when 'milestone' param does not exist" do
let(:params) { {} }
it "does not set the work item's milestone" do
expect { execute_callback }.to not_change(work_item, :milestone)
end
end
context "when 'milestone' is not in the work item's project's hierarchy" do
let(:another_group_milestone) { create(:milestone, group: create(:group)) }
let(:params) { { milestone_id: another_group_milestone.id } }
it "does not set the work item's milestone" do
expect { execute_callback }.to not_change(work_item, :milestone)
end
end
context 'when assigning a group milestone' do
let(:params) { { milestone_id: group_milestone.id } }
it "sets the work item's milestone" do
expect { execute_callback }
.to change(work_item, :milestone)
.from(nil)
.to(group_milestone)
end
end
context 'when assigning a project milestone' do
let(:params) { { milestone_id: project_milestone.id } }
it "sets the work item's milestone" do
expect { execute_callback }
.to change(work_item, :milestone)
.from(nil)
.to(project_milestone)
end
end
end
|