summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-04-24 12:24:34 -0500
committerDouwe Maan <douwe@selenight.nl>2017-04-24 12:24:39 -0500
commitbc4eeb96ae5c7de96f7e8e16aa508e3308f06c5b (patch)
treecd2aeeb688c93e4c3556f2c20e23e2074c76777a
parent1005389f70070245092c1ae5f3f9b10b8e7c102e (diff)
downloadgitlab-ce-dm-fix-individual-notes-reply-attributes.tar.gz
Ensure replying to an individual note by email creates a note with its own discussion IDdm-fix-individual-notes-reply-attributes
-rw-r--r--app/models/individual_note_discussion.rb4
-rw-r--r--app/models/out_of_context_discussion.rb6
-rw-r--r--changelogs/unreleased/dm-fix-individual-notes-reply-attributes.yml5
-rw-r--r--spec/models/sent_notification_spec.rb8
4 files changed, 22 insertions, 1 deletions
diff --git a/app/models/individual_note_discussion.rb b/app/models/individual_note_discussion.rb
index c3f21c55240..6be8ca45739 100644
--- a/app/models/individual_note_discussion.rb
+++ b/app/models/individual_note_discussion.rb
@@ -10,4 +10,8 @@ class IndividualNoteDiscussion < Discussion
def individual_note?
true
end
+
+ def reply_attributes
+ super.tap { |attrs| attrs.delete(:discussion_id) }
+ end
end
diff --git a/app/models/out_of_context_discussion.rb b/app/models/out_of_context_discussion.rb
index 85794630f70..4227c40b69a 100644
--- a/app/models/out_of_context_discussion.rb
+++ b/app/models/out_of_context_discussion.rb
@@ -15,8 +15,12 @@ class OutOfContextDiscussion < Discussion
def self.override_discussion_id(note)
discussion_id(note)
end
-
+
def self.note_class
Note
end
+
+ def reply_attributes
+ super.tap { |attrs| attrs.delete(:discussion_id) }
+ end
end
diff --git a/changelogs/unreleased/dm-fix-individual-notes-reply-attributes.yml b/changelogs/unreleased/dm-fix-individual-notes-reply-attributes.yml
new file mode 100644
index 00000000000..e8c05092ea8
--- /dev/null
+++ b/changelogs/unreleased/dm-fix-individual-notes-reply-attributes.yml
@@ -0,0 +1,5 @@
+---
+title: Ensure replying to an individual note by email creates a note with its own
+ discussion ID
+merge_request:
+author:
diff --git a/spec/models/sent_notification_spec.rb b/spec/models/sent_notification_spec.rb
index 6b7eef388be..5710edbc9e0 100644
--- a/spec/models/sent_notification_spec.rb
+++ b/spec/models/sent_notification_spec.rb
@@ -69,6 +69,7 @@ describe SentNotification, model: true do
it 'creates a comment on the issue' do
new_note = subject.create_reply('Test')
expect(new_note.in_reply_to?(note)).to be_truthy
+ expect(new_note.discussion_id).not_to eq(note.discussion_id)
end
end
@@ -79,6 +80,7 @@ describe SentNotification, model: true do
it 'creates a reply on the discussion' do
new_note = subject.create_reply('Test')
expect(new_note.in_reply_to?(note)).to be_truthy
+ expect(new_note.discussion_id).to eq(note.discussion_id)
end
end
@@ -99,6 +101,7 @@ describe SentNotification, model: true do
it 'creates a comment on the merge request' do
new_note = subject.create_reply('Test')
expect(new_note.in_reply_to?(note)).to be_truthy
+ expect(new_note.discussion_id).not_to eq(note.discussion_id)
end
end
@@ -109,6 +112,7 @@ describe SentNotification, model: true do
it 'creates a reply on the discussion' do
new_note = subject.create_reply('Test')
expect(new_note.in_reply_to?(note)).to be_truthy
+ expect(new_note.discussion_id).to eq(note.discussion_id)
end
end
@@ -119,6 +123,7 @@ describe SentNotification, model: true do
it 'creates a reply on the discussion' do
new_note = subject.create_reply('Test')
expect(new_note.in_reply_to?(note)).to be_truthy
+ expect(new_note.discussion_id).to eq(note.discussion_id)
end
end
@@ -140,6 +145,7 @@ describe SentNotification, model: true do
it 'creates a comment on the commit' do
new_note = subject.create_reply('Test')
expect(new_note.in_reply_to?(note)).to be_truthy
+ expect(new_note.discussion_id).not_to eq(note.discussion_id)
end
end
@@ -150,6 +156,7 @@ describe SentNotification, model: true do
it 'creates a reply on the discussion' do
new_note = subject.create_reply('Test')
expect(new_note.in_reply_to?(note)).to be_truthy
+ expect(new_note.discussion_id).to eq(note.discussion_id)
end
end
@@ -160,6 +167,7 @@ describe SentNotification, model: true do
it 'creates a reply on the discussion' do
new_note = subject.create_reply('Test')
expect(new_note.in_reply_to?(note)).to be_truthy
+ expect(new_note.discussion_id).to eq(note.discussion_id)
end
end
end