From 9f46488805e86b1bc341ea1620b866016c2ce5ed Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 20 May 2020 14:34:42 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-0-stable-ee --- spec/services/notes/create_service_spec.rb | 56 +++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'spec/services/notes/create_service_spec.rb') diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb index c461dd700ec..39d6fd26e31 100644 --- a/spec/services/notes/create_service_spec.rb +++ b/spec/services/notes/create_service_spec.rb @@ -342,6 +342,60 @@ describe Notes::CreateService do end end + context 'design note' do + subject(:service) { described_class.new(project, user, params) } + + let_it_be(:design) { create(:design, :with_file) } + let_it_be(:project) { design.project } + let_it_be(:user) { project.owner } + let_it_be(:params) do + { + type: 'DiffNote', + noteable: design, + note: "A message", + position: { + old_path: design.full_path, + new_path: design.full_path, + position_type: 'image', + width: '100', + height: '100', + x: '50', + y: '50', + base_sha: design.diff_refs.base_sha, + start_sha: design.diff_refs.base_sha, + head_sha: design.diff_refs.head_sha + } + } + end + + it 'can create diff notes for designs' do + note = service.execute + + expect(note).to be_a(DiffNote) + expect(note).to be_persisted + expect(note.noteable).to eq(design) + end + + it 'sends a notification about this note', :sidekiq_might_not_need_inline do + notifier = double + allow(::NotificationService).to receive(:new).and_return(notifier) + + expect(notifier) + .to receive(:new_note) + .with have_attributes(noteable: design) + + service.execute + end + + it 'correctly builds the position of the note' do + note = service.execute + + expect(note.position.new_path).to eq(design.full_path) + expect(note.position.old_path).to eq(design.full_path) + expect(note.position.diff_refs).to eq(design.diff_refs) + end + end + context 'note with emoji only' do it 'creates regular note' do opts = { @@ -371,7 +425,7 @@ describe Notes::CreateService do expect do existing_note - Timecop.freeze(Time.now + 1.minute) { subject } + Timecop.freeze(Time.current + 1.minute) { subject } existing_note.reload end.to change { existing_note.type }.from(nil).to('DiscussionNote') -- cgit v1.2.1