Commit 874413cf authored by Douwe Maan's avatar Douwe Maan Committed by Luke "Jared" Bennett

Fix specs

parent 79889a6a
...@@ -66,6 +66,7 @@ module Emails ...@@ -66,6 +66,7 @@ module Emails
def setup_note_mail(note_id, recipient_id) def setup_note_mail(note_id, recipient_id)
@note = Note.find(note_id) @note = Note.find(note_id)
@project = @note.project @project = @note.project
return unless @project
@sent_notification = SentNotification.record_note(@note, recipient_id, reply_key) @sent_notification = SentNotification.record_note(@note, recipient_id, reply_key)
end end
......
...@@ -111,7 +111,7 @@ class Notify < BaseMailer ...@@ -111,7 +111,7 @@ class Notify < BaseMailer
headers["X-GitLab-#{model.class.name}-ID"] = model.id headers["X-GitLab-#{model.class.name}-ID"] = model.id
headers['X-GitLab-Reply-Key'] = reply_key headers['X-GitLab-Reply-Key'] = reply_key
if Gitlab::IncomingEmail.enabled? if Gitlab::IncomingEmail.enabled? && @sent_notification
address = Mail::Address.new(Gitlab::IncomingEmail.reply_address(reply_key)) address = Mail::Address.new(Gitlab::IncomingEmail.reply_address(reply_key))
address.display_name = @project.name_with_namespace address.display_name = @project.name_with_namespace
...@@ -176,6 +176,6 @@ class Notify < BaseMailer ...@@ -176,6 +176,6 @@ class Notify < BaseMailer
end end
headers['List-Unsubscribe'] = list_unsubscribe_methods.map { |e| "<#{e}>" }.join(',') headers['List-Unsubscribe'] = list_unsubscribe_methods.map { |e| "<#{e}>" }.join(',')
@sent_notification_url = unsubscribe_sent_notification_url(@sent_notification) @unsubscribe_url = unsubscribe_sent_notification_url(@sent_notification)
end end
end end
...@@ -2,6 +2,8 @@ module Notes ...@@ -2,6 +2,8 @@ module Notes
class BuildService < BaseService class BuildService < BaseService
def execute def execute
in_reply_to_discussion_id = params.delete(:in_reply_to_discussion_id) in_reply_to_discussion_id = params.delete(:in_reply_to_discussion_id)
new_discussion = params.delete(:new_discussion)
if project && in_reply_to_discussion_id.present? if project && in_reply_to_discussion_id.present?
discussion = discussion =
project.notes.find_original_discussion(in_reply_to_discussion_id) || project.notes.find_original_discussion(in_reply_to_discussion_id) ||
...@@ -14,7 +16,7 @@ module Notes ...@@ -14,7 +16,7 @@ module Notes
end end
params.merge!(discussion.reply_attributes) params.merge!(discussion.reply_attributes)
elsif params.delete(:new_discussion) elsif new_discussion
# TODO: Remove when we use a selectbox instead of a submit button # TODO: Remove when we use a selectbox instead of a submit button
params[:type] = DiscussionNote.name params[:type] = DiscussionNote.name
end end
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
= link_to_reply_discussion(discussion, line_type) = link_to_reply_discussion(discussion, line_type)
= render "discussions/resolve_all", discussion: discussion = render "discussions/resolve_all", discussion: discussion
.btn-group.discussion-actions .btn-group.discussion-actions
= render "discussions/new_issue_for_discussion", discussion: discussion, merge_request: discussion.noteable = render "discussions/new_issue_for_discussion", discussion: discussion, merge_request: discussion.noteable
= render "discussions/jump_to_next", discussion: discussion = render "discussions/jump_to_next", discussion: discussion
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
- if @labels_url - if @labels_url
adjust your #{link_to 'label subscriptions', @labels_url}. adjust your #{link_to 'label subscriptions', @labels_url}.
- else - else
- if @sent_notification_url - if @unsubscribe_url
= link_to "unsubscribe", @sent_notification_url = link_to "unsubscribe", @unsubscribe_url
from this thread or from this thread or
adjust your notification settings. adjust your notification settings.
......
%p %p
You have been mentioned in an issue. You have been mentioned in an issue.
= render template: 'new_issue_email' = render template: 'notify/new_issue_email'
%p %p
You have been mentioned in Merge Request #{@merge_request.to_reference} You have been mentioned in Merge Request #{@merge_request.to_reference}
= render template: 'new_merge_request_email' = render template: 'notify/new_merge_request_email'
...@@ -2,7 +2,7 @@ FactoryGirl.define do ...@@ -2,7 +2,7 @@ FactoryGirl.define do
factory :sent_notification do factory :sent_notification do
project factory: :empty_project project factory: :empty_project
recipient factory: :user recipient factory: :user
noteable factory: :issue noteable { create(:issue, project: project) }
reply_key { SentNotification.reply_key } reply_key { SentNotification.reply_key }
end end
end end
require 'spec_helper' require 'spec_helper'
describe DiscussionNote, models: true do describe DiscussionNote, models: true do
end end
require 'spec_helper' require 'spec_helper'
describe IndividualNoteDiscussion, models: true do describe IndividualNoteDiscussion, models: true do
end end
require 'spec_helper' require 'spec_helper'
describe OutOfContextDiscussion, model: true do describe OutOfContextDiscussion, model: true do
end end
...@@ -4,7 +4,7 @@ describe SentNotification, model: true do ...@@ -4,7 +4,7 @@ describe SentNotification, model: true do
describe 'validation' do describe 'validation' do
describe 'note validity' do describe 'note validity' do
context "when the project doesn't match the noteable's project" do context "when the project doesn't match the noteable's project" do
subject { build(:sent_notification, project: create(:project)) } subject { build(:sent_notification, noteable: create(:issue)) }
it "is invalid" do it "is invalid" do
expect(subject).not_to be_valid expect(subject).not_to be_valid
......
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