mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 09:48:06 +08:00
FIX: wasn't able to parse FROM email in the embedded email
This commit is contained in:
@ -383,6 +383,32 @@ describe Email::Receiver do
|
||||
expect(Post.last.raw).to match(/discourse\.rb/)
|
||||
end
|
||||
|
||||
it "handles forwarded emails" do
|
||||
SiteSetting.enable_forwarded_emails = true
|
||||
expect { process(:forwarded_email_1) }.to change(Topic, :count)
|
||||
|
||||
forwarded_post, last_post = *Post.last(2)
|
||||
|
||||
expect(forwarded_post.user.email).to eq("some@one.com")
|
||||
expect(last_post.user.email).to eq("ba@bar.com")
|
||||
|
||||
expect(forwarded_post.raw).to match(/XoXo/)
|
||||
expect(last_post.raw).to match(/can you have a look at this email below/)
|
||||
end
|
||||
|
||||
it "handles weirdly forwarded emails" do
|
||||
SiteSetting.enable_forwarded_emails = true
|
||||
expect { process(:forwarded_email_2) }.to change(Topic, :count)
|
||||
|
||||
forwarded_post, last_post = *Post.last(2)
|
||||
|
||||
expect(forwarded_post.user.email).to eq("some@one.com")
|
||||
expect(last_post.user.email).to eq("ba@bar.com")
|
||||
|
||||
expect(forwarded_post.raw).to match(/XoXo/)
|
||||
expect(last_post.raw).to match(/can you have a look at this email below/)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "new topic in a category" do
|
||||
|
18
spec/fixtures/emails/forwarded_email_1.eml
vendored
Normal file
18
spec/fixtures/emails/forwarded_email_1.eml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
Message-ID: <58@foo.bar.mail>
|
||||
From: Ba Bar <ba@bar.com>
|
||||
To: Team <team@bar.com>
|
||||
Date: Mon, 1 Dec 2016 13:37:42 +0100
|
||||
Subject: FW: Discoursing much?
|
||||
|
||||
@team, can you have a look at this email below?
|
||||
|
||||
From: Some One <some@one.com>
|
||||
To: Ba Bar <ba@bar.com>
|
||||
Date: Mon, 1 Dec 2016 00:13:37 +0100
|
||||
Subject: Discoursing much?
|
||||
|
||||
Hello Ba Bar,
|
||||
|
||||
Discoursing much today?
|
||||
|
||||
XoXo
|
18
spec/fixtures/emails/forwarded_email_2.eml
vendored
Normal file
18
spec/fixtures/emails/forwarded_email_2.eml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
Message-ID: <59@foo.bar.mail>
|
||||
From: Ba Bar <ba@bar.com>
|
||||
To: Team <team@bar.com>
|
||||
Date: Mon, 1 Dec 2016 13:37:42 +0100
|
||||
Subject: Re: Discoursing much?
|
||||
|
||||
@team, can you have a look at this email below?
|
||||
|
||||
From: Some One [mailto:some@one.com]
|
||||
To: Ba Bar <ba@bar.com>
|
||||
Date: Mon, 1 Dec 2016 00:13:37 +0100
|
||||
Subject: Discoursing much?
|
||||
|
||||
Hello Ba Bar,
|
||||
|
||||
Discoursing much today?
|
||||
|
||||
XoXo
|
Reference in New Issue
Block a user