debian-mirror-gitlab/spec/services/notes/post_process_service_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
2.2 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2016-04-02 18:10:28 +05:30
require 'spec_helper'
2023-05-27 22:25:52 +05:30
RSpec.describe Notes::PostProcessService, feature_category: :team_planning do
2017-09-10 17:25:29 +05:30
let(:project) { create(:project) }
2016-04-02 18:10:28 +05:30
let(:issue) { create(:issue, project: project) }
let(:user) { create(:user) }
2016-08-24 12:49:21 +05:30
describe '#execute' do
2016-04-02 18:10:28 +05:30
before do
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2016-04-02 18:10:28 +05:30
note_opts = {
note: 'Awesome comment',
noteable_type: 'Issue',
noteable_id: issue.id
}
@note = Notes::CreateService.new(project, user, note_opts).execute
end
it do
expect(project).to receive(:execute_hooks)
2021-09-30 23:02:18 +05:30
expect(project).to receive(:execute_integrations)
2016-04-02 18:10:28 +05:30
2017-09-10 17:25:29 +05:30
described_class.new(@note).execute
2016-04-02 18:10:28 +05:30
end
2018-04-05 14:03:07 +05:30
context 'with a confidential issue' do
let(:issue) { create(:issue, :confidential, project: project) }
2021-09-30 23:02:18 +05:30
it "doesn't call note hooks/integrations" do
2018-04-05 14:03:07 +05:30
expect(project).not_to receive(:execute_hooks).with(anything, :note_hooks)
2021-09-30 23:02:18 +05:30
expect(project).not_to receive(:execute_integrations).with(anything, :note_hooks)
2018-04-05 14:03:07 +05:30
described_class.new(@note).execute
end
2021-09-30 23:02:18 +05:30
it "calls confidential-note hooks/integrations" do
2018-04-05 14:03:07 +05:30
expect(project).to receive(:execute_hooks).with(anything, :confidential_note_hooks)
2021-09-30 23:02:18 +05:30
expect(project).to receive(:execute_integrations).with(anything, :confidential_note_hooks)
2018-04-05 14:03:07 +05:30
described_class.new(@note).execute
end
end
2020-05-24 23:13:21 +05:30
context 'when the noteable is a design' do
let_it_be(:noteable) { create(:design, :with_file) }
let_it_be(:discussion_note) { create_note }
subject { described_class.new(note).execute }
def create_note(in_reply_to: nil)
create(:diff_note_on_design, noteable: noteable, in_reply_to: in_reply_to)
end
context 'when the note is the start of a new discussion' do
let(:note) { discussion_note }
it 'creates a new system note' do
expect { subject }.to change { Note.system.count }.by(1)
end
end
context 'when the note is a reply within a discussion' do
let_it_be(:note) { create_note(in_reply_to: discussion_note) }
it 'does not create a new system note' do
expect { subject }.not_to change { Note.system.count }
end
end
end
2016-04-02 18:10:28 +05:30
end
end