diff options
author | Heinrich Lee Yu <heinrich@gitlab.com> | 2019-02-06 13:31:46 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-02-06 13:31:46 +0300 |
commit | a04d9ba90c0d1df02f613b7aa01ef598e1ac5b28 (patch) | |
tree | 4a8889592e2290160926ede70aa0cf37bd93519f /spec/models/sent_notification_spec.rb | |
parent | c5f1b8346860aa764369a3d156047c9e2c7317ca (diff) |
Add reply to notes to turn into discussions
Diffstat (limited to 'spec/models/sent_notification_spec.rb')
-rw-r--r-- | spec/models/sent_notification_spec.rb | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/spec/models/sent_notification_spec.rb b/spec/models/sent_notification_spec.rb index 677613b7980..6c35ed8f649 100644 --- a/spec/models/sent_notification_spec.rb +++ b/spec/models/sent_notification_spec.rb @@ -36,19 +36,41 @@ describe SentNotification do end end + shared_examples 'a successful sent notification' do + it 'creates a new SentNotification' do + expect { subject }.to change { described_class.count }.by(1) + end + end + describe '.record' do let(:issue) { create(:issue) } - it 'creates a new SentNotification' do - expect { described_class.record(issue, user.id) }.to change { described_class.count }.by(1) - end + subject { described_class.record(issue, user.id) } + + it_behaves_like 'a successful sent notification' end describe '.record_note' do - let(:note) { create(:diff_note_on_merge_request) } + subject { described_class.record_note(note, note.author.id) } - it 'creates a new SentNotification' do - expect { described_class.record_note(note, note.author.id) }.to change { described_class.count }.by(1) + context 'for a discussion note' do + let(:note) { create(:diff_note_on_merge_request) } + + it_behaves_like 'a successful sent notification' + + it 'sets in_reply_to_discussion_id' do + expect(subject.in_reply_to_discussion_id).to eq(note.discussion_id) + end + end + + context 'for an individual note' do + let(:note) { create(:note_on_merge_request) } + + it_behaves_like 'a successful sent notification' + + it 'does not set in_reply_to_discussion_id' do + expect(subject.in_reply_to_discussion_id).to be_nil + end end end |