Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-18 11:17:02 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-18 11:17:02 +0300
commitb39512ed755239198a9c294b6a45e65c05900235 (patch)
treed234a3efade1de67c46b9e5a38ce813627726aa7 /spec/services/issuable
parentd31474cf3b17ece37939d20082b07f6657cc79a9 (diff)
Add latest changes from gitlab-org/gitlab@15-3-stable-eev15.3.0-rc42
Diffstat (limited to 'spec/services/issuable')
-rw-r--r--spec/services/issuable/common_system_notes_service_spec.rb45
1 files changed, 39 insertions, 6 deletions
diff --git a/spec/services/issuable/common_system_notes_service_spec.rb b/spec/services/issuable/common_system_notes_service_spec.rb
index 1426ef2a1f6..0d2b8a4ac3c 100644
--- a/spec/services/issuable/common_system_notes_service_spec.rb
+++ b/spec/services/issuable/common_system_notes_service_spec.rb
@@ -8,6 +8,37 @@ RSpec.describe Issuable::CommonSystemNotesService do
let(:issuable) { create(:issue, project: project) }
+ shared_examples 'system note for issuable date changes' do
+ it 'creates a system note for due_date set' do
+ issuable.update!(due_date: Date.today)
+
+ expect { subject }.to change(issuable.notes, :count).from(0).to(1)
+ expect(issuable.notes.last.note).to match('changed due date to')
+ end
+
+ it 'creates a system note for start_date set' do
+ issuable.update!(start_date: Date.today)
+
+ expect { subject }.to change(issuable.notes, :count).from(0).to(1)
+ expect(issuable.notes.last.note).to match('changed start date to')
+ end
+
+ it 'creates a note when both start and due date are changed' do
+ issuable.update!(start_date: Date.today, due_date: 1.week.from_now)
+
+ expect { subject }.to change { issuable.notes.count }.from(0).to(1)
+ expect(issuable.notes.last.note).to match(/changed start date to.+and changed due date to/)
+ end
+
+ it 'does not call SystemNoteService if no dates are changed' do
+ issuable.update!(title: 'new title')
+
+ expect(SystemNoteService).not_to receive(:change_start_date_or_due_date)
+
+ subject
+ end
+ end
+
context 'on issuable update' do
it_behaves_like 'system note creation', { title: 'New title' }, 'changed title'
it_behaves_like 'system note creation', { description: 'New description' }, 'changed the description'
@@ -61,6 +92,12 @@ RSpec.describe Issuable::CommonSystemNotesService do
end
end
end
+
+ context 'when changing dates' do
+ it_behaves_like 'system note for issuable date changes' do
+ subject { described_class.new(project: project, current_user: user).execute(issuable) }
+ end
+ end
end
context 'on issuable create' do
@@ -102,12 +139,8 @@ RSpec.describe Issuable::CommonSystemNotesService do
end
end
- it 'creates a system note for due_date set' do
- issuable.due_date = Date.today
- issuable.save!
-
- expect { subject }.to change { issuable.notes.count }.from(0).to(1)
- expect(issuable.notes.last.note).to match('changed due date')
+ context 'when changing dates' do
+ it_behaves_like 'system note for issuable date changes'
end
end
end