FIX: List-ID should not contain space

This commit is contained in:
Arpit Jalan 2015-10-21 00:00:06 +05:30
parent 717be06f17
commit 897563a309
2 changed files with 6 additions and 3 deletions

View File

@ -87,12 +87,12 @@ module Email
# http://www.ietf.org/rfc/rfc2919.txt
if topic && topic.category && !topic.category.uncategorized?
list_id = "<#{topic.category.name.downcase}.#{host}>"
list_id = "<#{topic.category.name.downcase.split(' ').join('-')}.#{host}>"
# subcategory case
if !topic.category.parent_category_id.nil?
parent_category_name = Category.find_by(id: topic.category.parent_category_id).name
list_id = "<#{topic.category.name.downcase}.#{parent_category_name.downcase}.#{host}>"
list_id = "<#{topic.category.name.downcase.split(' ').join('-')}.#{parent_category_name.downcase.split(' ').join('-')}.#{host}>"
end
else
list_id = "<#{host}>"

View File

@ -66,11 +66,14 @@ describe Email::Sender do
context "adds a List-ID header to identify the forum" do
before do
message.header['X-Discourse-Topic-Id'] = 5577
category = Fabricate(:category, name: 'Name With Space')
topic = Fabricate(:topic, category_id: category.id)
message.header['X-Discourse-Topic-Id'] = topic.id
end
When { email_sender.send }
Then { expect(message.header['List-ID']).to be_present }
Then { expect(message.header['List-ID'].to_s).to match('name-with-space') }
end
context "adds a Message-ID header even when topic id is not present" do