mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 20:41:24 +08:00
Remove RSpec given.
This commit is contained in:
@ -80,19 +80,19 @@ describe Email::Sender do
|
||||
context "doesn't add return_path when no plus addressing" do
|
||||
before { SiteSetting.reply_by_email_address = '%{reply_key}@test.com' }
|
||||
|
||||
When { email_sender.send }
|
||||
Then {
|
||||
it 'should not set the return_path' do
|
||||
email_sender.send
|
||||
expect(message.header[:return_path].to_s).to eq("")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
context "adds return_path with plus addressing" do
|
||||
before { SiteSetting.reply_by_email_address = 'replies+%{reply_key}@test.com' }
|
||||
|
||||
When { email_sender.send }
|
||||
Then {
|
||||
it 'should set the return_path' do
|
||||
email_sender.send
|
||||
expect(message.header[:return_path].to_s).to eq("replies+verp-#{EmailLog.last.bounce_key}@test.com")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
context "adds a List-ID header to identify the forum" do
|
||||
@ -102,14 +102,21 @@ describe Email::Sender do
|
||||
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') }
|
||||
it 'should add the right header' do
|
||||
email_sender.send
|
||||
|
||||
expect(message.header['List-ID']).to be_present
|
||||
expect(message.header['List-ID'].to_s).to match('name-with-space')
|
||||
end
|
||||
end
|
||||
|
||||
context "adds a Message-ID header even when topic id is not present" do
|
||||
When { email_sender.send }
|
||||
Then { expect(message.header['Message-ID']).to be_present }
|
||||
|
||||
it 'should add the right header' do
|
||||
email_sender.send
|
||||
|
||||
expect(message.header['Message-ID']).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
context "adds Precedence header" do
|
||||
@ -117,8 +124,10 @@ describe Email::Sender do
|
||||
message.header['X-Discourse-Topic-Id'] = 5577
|
||||
end
|
||||
|
||||
When { email_sender.send }
|
||||
Then { expect(message.header['Precedence']).to be_present }
|
||||
it 'should add the right header' do
|
||||
email_sender.send
|
||||
expect(message.header['Precedence']).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
context "removes custom Discourse headers from topic notification mails" do
|
||||
@ -126,17 +135,21 @@ describe Email::Sender do
|
||||
message.header['X-Discourse-Topic-Id'] = 5577
|
||||
end
|
||||
|
||||
When { email_sender.send }
|
||||
Then { expect(message.header['X-Discourse-Topic-Id']).not_to be_present }
|
||||
Then { expect(message.header['X-Discourse-Post-Id']).not_to be_present }
|
||||
Then { expect(message.header['X-Discourse-Reply-Key']).not_to be_present }
|
||||
it 'should remove the right headers' do
|
||||
email_sender.send
|
||||
expect(message.header['X-Discourse-Topic-Id']).not_to be_present
|
||||
expect(message.header['X-Discourse-Post-Id']).not_to be_present
|
||||
expect(message.header['X-Discourse-Reply-Key']).not_to be_present
|
||||
end
|
||||
end
|
||||
|
||||
context "removes custom Discourse headers from digest/registration/other mails" do
|
||||
When { email_sender.send }
|
||||
Then { expect(message.header['X-Discourse-Topic-Id']).not_to be_present }
|
||||
Then { expect(message.header['X-Discourse-Post-Id']).not_to be_present }
|
||||
Then { expect(message.header['X-Discourse-Reply-Key']).not_to be_present }
|
||||
it 'should remove the right headers' do
|
||||
email_sender.send
|
||||
expect(message.header['X-Discourse-Topic-Id']).not_to be_present
|
||||
expect(message.header['X-Discourse-Post-Id']).not_to be_present
|
||||
expect(message.header['X-Discourse-Reply-Key']).not_to be_present
|
||||
end
|
||||
end
|
||||
|
||||
context "email threading" do
|
||||
@ -214,8 +227,10 @@ describe Email::Sender do
|
||||
message.header['X-MC-Metadata'] = { foo: "bar" }.to_json
|
||||
end
|
||||
|
||||
When { email_sender.send }
|
||||
Then { expect(message.header['X-MC-Metadata'].to_s).to match(message.message_id) }
|
||||
it 'should set the right header' do
|
||||
email_sender.send
|
||||
expect(message.header['X-MC-Metadata'].to_s).to match(message.message_id)
|
||||
end
|
||||
end
|
||||
|
||||
context "merges custom sparkpost header" do
|
||||
@ -224,19 +239,24 @@ describe Email::Sender do
|
||||
message.header['X-MSYS-API'] = { foo: "bar" }.to_json
|
||||
end
|
||||
|
||||
When { email_sender.send }
|
||||
Then { expect(message.header['X-MSYS-API'].to_s).to match(message.message_id) }
|
||||
it 'should set the right header' do
|
||||
email_sender.send
|
||||
expect(message.header['X-MSYS-API'].to_s).to match(message.message_id)
|
||||
end
|
||||
end
|
||||
|
||||
context 'email logs' do
|
||||
let(:email_log) { EmailLog.last }
|
||||
|
||||
When { email_sender.send }
|
||||
Then { expect(email_log).to be_present }
|
||||
Then { expect(email_log.email_type).to eq('valid_type') }
|
||||
Then { expect(email_log.to_address).to eq('eviltrout@test.domain') }
|
||||
Then { expect(email_log.reply_key).to be_blank }
|
||||
Then { expect(email_log.user_id).to be_blank }
|
||||
it 'should create the right log' do
|
||||
email_sender.send
|
||||
|
||||
expect(email_log).to be_present
|
||||
expect(email_log.email_type).to eq('valid_type')
|
||||
expect(email_log.to_address).to eq('eviltrout@test.domain')
|
||||
expect(email_log.reply_key).to be_blank
|
||||
expect(email_log.user_id).to be_blank
|
||||
end
|
||||
end
|
||||
|
||||
context "email log with a post id and topic id" do
|
||||
@ -246,9 +266,12 @@ describe Email::Sender do
|
||||
end
|
||||
|
||||
let(:email_log) { EmailLog.last }
|
||||
When { email_sender.send }
|
||||
Then { expect(email_log.post_id).to eq(3344) }
|
||||
Then { expect(email_log.topic_id).to eq(5577) }
|
||||
|
||||
it 'should create the right log' do
|
||||
email_sender.send
|
||||
expect(email_log.post_id).to eq(3344)
|
||||
expect(email_log.topic_id).to eq(5577)
|
||||
end
|
||||
end
|
||||
|
||||
context "email log with a reply key" do
|
||||
@ -257,17 +280,23 @@ describe Email::Sender do
|
||||
end
|
||||
|
||||
let(:email_log) { EmailLog.last }
|
||||
When { email_sender.send }
|
||||
Then { expect(email_log.reply_key).to eq(reply_key) }
|
||||
|
||||
it 'should create the right log' do
|
||||
email_sender.send
|
||||
expect(email_log.reply_key).to eq(reply_key)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context 'email parts' do
|
||||
When { email_sender.send }
|
||||
Then { expect(message).to be_multipart }
|
||||
Then { expect(message.text_part.content_type).to eq('text/plain; charset=UTF-8') }
|
||||
Then { expect(message.html_part.content_type).to eq('text/html; charset=UTF-8') }
|
||||
Then { expect(message.html_part.body.to_s).to match("<p><strong>hello</strong></p>") }
|
||||
it 'should contain the right message' do
|
||||
email_sender.send
|
||||
|
||||
expect(message).to be_multipart
|
||||
expect(message.text_part.content_type).to eq('text/plain; charset=UTF-8')
|
||||
expect(message.html_part.content_type).to eq('text/html; charset=UTF-8')
|
||||
expect(message.html_part.body.to_s).to match("<p><strong>hello</strong></p>")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user