From fbc5d91ae9b68b3c4ad450a22055a74dfce1caf9 Mon Sep 17 00:00:00 2001 From: Rafael Masson Date: Mon, 26 Mar 2018 16:48:02 -0400 Subject: [PATCH] Make References field singular like In-Reply-To Closes #1220 --- lib/mail/fields/references_field.rb | 4 ++++ spec/mail/message_spec.rb | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/mail/fields/references_field.rb b/lib/mail/fields/references_field.rb index bb2a7e2d2..964c11064 100644 --- a/lib/mail/fields/references_field.rb +++ b/lib/mail/fields/references_field.rb @@ -31,6 +31,10 @@ module Mail class ReferencesField < CommonMessageIdField #:nodoc: NAME = 'References' + def self.singular? + true + end + def initialize(value = nil, charset = nil) value = value.join("\r\n\s") if value.is_a?(Array) super value, charset diff --git a/spec/mail/message_spec.rb b/spec/mail/message_spec.rb index 224d1ab8d..307c0dc26 100644 --- a/spec/mail/message_spec.rb +++ b/spec/mail/message_spec.rb @@ -165,6 +165,16 @@ def create_mail_with_splat_args expect(Mail::Utilities.blank?(mail.in_reply_to)).to be_truthy end + it "should be able to pass two In-Reply-To headers" do + mail = Mail.new("From: bob\r\nIn-Reply-To: \r\nIn-Reply-To: \r\nSubject: Hello!\r\n\r\nemail message\r\n") + expect(mail.in_reply_to).to eq 'b@b.b' + end + + it "should be able to pass two References headers" do + mail = Mail.new("From: bob\r\nReferences: \r\nReferences: \r\nSubject: Hello!\r\n\r\nemail message\r\n") + expect(mail.references).to eq 'b@b.b' + end + describe "YAML serialization" do before(:each) do # Ensure specs don't randomly fail due to messages being generated 1 second apart