Added In-Reply-To and References email headers. Additionally removed username from

email replies and new posts to keep the subjects collapsable.
This commit is contained in:
Robin Ward
2013-07-08 11:48:40 -04:00
parent 4ddd50fe17
commit 013ad0fdda
3 changed files with 51 additions and 30 deletions

View File

@ -20,32 +20,37 @@ describe Email::Sender do
Email::Sender.new(message, :hello).send
end
context "host_for" do
it "defaults to localhost" do
Email::Sender.host_for(nil).should == "localhost"
end
it "returns localhost for a weird host" do
Email::Sender.host_for("this is not a real host").should == "localhost"
end
it "parses hosts from urls" do
Email::Sender.host_for("http://meta.discourse.org").should == "meta.discourse.org"
end
it "downcases hosts" do
Email::Sender.host_for("http://ForumSite.com").should == "forumsite.com"
end
end
context "list_id_for" do
it "joins the host and forum name" do
Email::Sender.list_id_for("myforum", "http://mysite.com").should == '"myforum" <discourse.forum.myforum.mysite.com>'
end
it "uses localhost when no host is present" do
Email::Sender.list_id_for("myforum", nil).should == '"myforum" <discourse.forum.myforum.localhost>'
end
it "uses localhost with a weird host" do
Email::Sender.list_id_for("Fun", "this is not a real host").should == '"Fun" <discourse.forum.fun.localhost>'
Email::Sender.list_id_for("myforum", "mysite.com").should == '"myforum" <discourse.forum.myforum.mysite.com>'
end
it "removes double quotes from names" do
Email::Sender.list_id_for('Quoted "Forum"', 'http://quoted.com').should == '"Quoted \'Forum\'" <discourse.forum.quoted-forum.quoted.com>'
Email::Sender.list_id_for('Quoted "Forum"', 'quoted.com').should == '"Quoted \'Forum\'" <discourse.forum.quoted-forum.quoted.com>'
end
it "converts the site name to lower case and removes spaces" do
Email::Sender.list_id_for("Robin's cool Forum!", "http://robin.com").should == '"Robin\'s cool Forum!" <discourse.forum.robins-cool-forum.robin.com>'
Email::Sender.list_id_for("Robin's cool Forum!", "robin.com").should == '"Robin\'s cool Forum!" <discourse.forum.robins-cool-forum.robin.com>'
end
it "downcases host names" do
Email::Sender.list_id_for("cool", "http://ForumSite.com").should == '"cool" <discourse.forum.cool.forumsite.com>'
end
end
context 'with a valid message' do
@ -92,6 +97,9 @@ describe Email::Sender do
When { email_sender.send }
Then { expect(email_log.post_id).to eq(3344) }
Then { expect(email_log.topic_id).to eq(5577) }
Then { expect(message.header['In-Reply-To']).to be_present }
Then { expect(message.header['References']).to be_present }
end
context "email log with a reply key" do