Commit 2f0fb20e authored by Sean McGivern's avatar Sean McGivern Committed by Rémy Coutable

Merge branch 'preserve-note_type-and-position' into 'master'

Preserve note_type and position for notes from emails

Closes #23208

See merge request !7010
parent 1eeaba10
...@@ -44,6 +44,7 @@ Please view this file on the master branch, on stable branches it's out of date. ...@@ -44,6 +44,7 @@ Please view this file on the master branch, on stable branches it's out of date.
- Speed-up group milestones show page - Speed-up group milestones show page
- Fix inconsistent options dropdown caret on mobile viewports (ClemMakesApps) - Fix inconsistent options dropdown caret on mobile viewports (ClemMakesApps)
- Extract project#update_merge_requests and SystemHooks to its own worker from GitPushService - Extract project#update_merge_requests and SystemHooks to its own worker from GitPushService
- Fix discussion thread from emails for merge requests. !7010
- Don't include archived projects when creating group milestones. !4940 (Jeroen Jacobs) - Don't include archived projects when creating group milestones. !4940 (Jeroen Jacobs)
- Add tag shortcut from the Commit page. !6543 - Add tag shortcut from the Commit page. !6543
- Keep refs for each deployment - Keep refs for each deployment
......
...@@ -46,7 +46,9 @@ module Gitlab ...@@ -46,7 +46,9 @@ module Gitlab
noteable_type: sent_notification.noteable_type, noteable_type: sent_notification.noteable_type,
noteable_id: sent_notification.noteable_id, noteable_id: sent_notification.noteable_id,
commit_id: sent_notification.commit_id, commit_id: sent_notification.commit_id,
line_code: sent_notification.line_code line_code: sent_notification.line_code,
position: sent_notification.position,
type: sent_notification.note_type
).execute ).execute
end end
end end
......
...@@ -23,8 +23,6 @@ Cool! ...@@ -23,8 +23,6 @@ Cool!
/close /close
/todo /todo
/due tomorrow
On Sun, Jun 9, 2013 at 1:39 PM, eviltrout via Discourse Meta On Sun, Jun 9, 2013 at 1:39 PM, eviltrout via Discourse Meta
<reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo> wrote: <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo> wrote:
......
...@@ -21,8 +21,6 @@ X-Scanned-By: MIMEDefang 2.69 on IPv6:2001:470:1d:165::1 ...@@ -21,8 +21,6 @@ X-Scanned-By: MIMEDefang 2.69 on IPv6:2001:470:1d:165::1
/close /close
/todo /todo
/due tomorrow
On Sun, Jun 9, 2013 at 1:39 PM, eviltrout via Discourse Meta On Sun, Jun 9, 2013 at 1:39 PM, eviltrout via Discourse Meta
<reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo> wrote: <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo> wrote:
......
...@@ -12,10 +12,13 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do ...@@ -12,10 +12,13 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do
let(:email_raw) { fixture_file('emails/valid_reply.eml') } let(:email_raw) { fixture_file('emails/valid_reply.eml') }
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
let(:noteable) { create(:issue, project: project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:note) { create(:diff_note_on_merge_request, project: project) }
let(:noteable) { note.noteable }
let!(:sent_notification) { SentNotification.record(noteable, user.id, mail_key) } let!(:sent_notification) do
SentNotification.record_note(note, user.id, mail_key)
end
context "when the recipient address doesn't include a mail key" do context "when the recipient address doesn't include a mail key" do
let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub(mail_key, "") } let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub(mail_key, "") }
...@@ -82,7 +85,6 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do ...@@ -82,7 +85,6 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do
expect { receiver.execute }.to change { noteable.notes.count }.by(1) expect { receiver.execute }.to change { noteable.notes.count }.by(1)
expect(noteable.reload).to be_closed expect(noteable.reload).to be_closed
expect(noteable.due_date).to eq(Date.tomorrow)
expect(TodoService.new.todo_exist?(noteable, user)).to be_truthy expect(TodoService.new.todo_exist?(noteable, user)).to be_truthy
end end
end end
...@@ -100,7 +102,6 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do ...@@ -100,7 +102,6 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do
expect { receiver.execute }.to change { noteable.notes.count }.by(1) expect { receiver.execute }.to change { noteable.notes.count }.by(1)
expect(noteable.reload).to be_open expect(noteable.reload).to be_open
expect(noteable.due_date).to be_nil
expect(TodoService.new.todo_exist?(noteable, user)).to be_falsy expect(TodoService.new.todo_exist?(noteable, user)).to be_falsy
end end
end end
...@@ -117,7 +118,6 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do ...@@ -117,7 +118,6 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do
expect { receiver.execute }.to change { noteable.notes.count }.by(2) expect { receiver.execute }.to change { noteable.notes.count }.by(2)
expect(noteable.reload).to be_closed expect(noteable.reload).to be_closed
expect(noteable.due_date).to eq(Date.tomorrow)
expect(TodoService.new.todo_exist?(noteable, user)).to be_truthy expect(TodoService.new.todo_exist?(noteable, user)).to be_truthy
end end
end end
...@@ -138,10 +138,11 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do ...@@ -138,10 +138,11 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do
it "creates a comment" do it "creates a comment" do
expect { receiver.execute }.to change { noteable.notes.count }.by(1) expect { receiver.execute }.to change { noteable.notes.count }.by(1)
note = noteable.notes.last new_note = noteable.notes.last
expect(note.author).to eq(sent_notification.recipient) expect(new_note.author).to eq(sent_notification.recipient)
expect(note.note).to include("I could not disagree more.") expect(new_note.position).to eq(note.position)
expect(new_note.note).to include("I could not disagree more.")
end end
it "adds all attachments" do it "adds all attachments" do
...@@ -160,10 +161,11 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do ...@@ -160,10 +161,11 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do
shared_examples 'an email that contains a mail key' do |header| shared_examples 'an email that contains a mail key' do |header|
it "fetches the mail key from the #{header} header and creates a comment" do it "fetches the mail key from the #{header} header and creates a comment" do
expect { receiver.execute }.to change { noteable.notes.count }.by(1) expect { receiver.execute }.to change { noteable.notes.count }.by(1)
note = noteable.notes.last new_note = noteable.notes.last
expect(note.author).to eq(sent_notification.recipient) expect(new_note.author).to eq(sent_notification.recipient)
expect(note.note).to include('I could not disagree more.') expect(new_note.position).to eq(note.position)
expect(new_note.note).to include('I could not disagree more.')
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment