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
def setup_note_mail(note_id, recipient_id)
@note = Note.find(note_id)
@project = @note.project
return unless @project
@sent_notification = SentNotification.record_note(@note, recipient_id, reply_key)
end
......
......@@ -111,7 +111,7 @@ class Notify < BaseMailer
headers["X-GitLab-#{model.class.name}-ID"] = model.id
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.display_name = @project.name_with_namespace
......@@ -176,6 +176,6 @@ class Notify < BaseMailer
end
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
......@@ -2,6 +2,8 @@ module Notes
class BuildService < BaseService
def execute
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?
discussion =
project.notes.find_original_discussion(in_reply_to_discussion_id) ||
......@@ -14,7 +16,7 @@ module Notes
end
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
params[:type] = DiscussionNote.name
end
......
......@@ -25,8 +25,8 @@
- if @labels_url
adjust your #{link_to 'label subscriptions', @labels_url}.
- else
- if @sent_notification_url
= link_to "unsubscribe", @sent_notification_url
- if @unsubscribe_url
= link_to "unsubscribe", @unsubscribe_url
from this thread or
adjust your notification settings.
......
%p
You have been mentioned in an issue.
= render template: 'new_issue_email'
= render template: 'notify/new_issue_email'
%p
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
factory :sent_notification do
project factory: :empty_project
recipient factory: :user
noteable factory: :issue
noteable { create(:issue, project: project) }
reply_key { SentNotification.reply_key }
end
end
require 'spec_helper'
describe DiscussionNote, models: true do
end
require 'spec_helper'
describe IndividualNoteDiscussion, models: true do
end
require 'spec_helper'
describe OutOfContextDiscussion, model: true do
end
......@@ -4,7 +4,7 @@ describe SentNotification, model: true do
describe 'validation' do
describe 'note validity' 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
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