diff options
Diffstat (limited to 'spec/services/notes/build_service_spec.rb')
-rw-r--r-- | spec/services/notes/build_service_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/services/notes/build_service_spec.rb b/spec/services/notes/build_service_spec.rb index 9aaccb4bffe..af4daff336b 100644 --- a/spec/services/notes/build_service_spec.rb +++ b/spec/services/notes/build_service_spec.rb @@ -123,6 +123,46 @@ describe Notes::BuildService do end end + context 'when replying to individual note' do + let(:note) { create(:note_on_issue) } + + subject { described_class.new(project, author, note: 'Test', in_reply_to_discussion_id: note.discussion_id).execute } + + shared_examples 'an individual note reply' do + it 'builds another individual note' do + expect(subject).to be_valid + expect(subject).to be_a(Note) + expect(subject.discussion_id).not_to eq(note.discussion_id) + end + end + + context 'when reply_to_individual_notes is disabled' do + before do + stub_feature_flags(reply_to_individual_notes: false) + end + + it_behaves_like 'an individual note reply' + end + + context 'when reply_to_individual_notes is enabled' do + before do + stub_feature_flags(reply_to_individual_notes: true) + end + + it 'sets the note up to be in reply to that note' do + expect(subject).to be_valid + expect(subject).to be_a(DiscussionNote) + expect(subject.discussion_id).to eq(note.discussion_id) + end + + context 'when noteable does not support replies' do + let(:note) { create(:note_on_commit) } + + it_behaves_like 'an individual note reply' + end + end + end + it 'builds a note without saving it' do new_note = described_class.new(project, author, |