FIX: use digest_min_excerpt_length site setting in summary emails
This commit is contained in:
parent
2f54eab9a6
commit
34a0e79bec
|
@ -39,7 +39,7 @@ module UserNotificationsHelper
|
|||
doc.css('body > p, aside.onebox').each do |node|
|
||||
if node.text.present?
|
||||
result << node.to_s
|
||||
return result if result.size >= 100
|
||||
return result if result.size >= SiteSetting.digest_min_excerpt_length
|
||||
end
|
||||
end
|
||||
return result unless result.blank?
|
||||
|
@ -48,9 +48,8 @@ module UserNotificationsHelper
|
|||
doc.css('div').first
|
||||
end
|
||||
|
||||
def email_excerpt(html_arg, posts_count = nil)
|
||||
# only include 1st paragraph when more than 1 posts
|
||||
html = (posts_count.nil? || posts_count > 1) ? (first_paragraph_from(html_arg) || html_arg).to_s : html_arg
|
||||
def email_excerpt(html_arg)
|
||||
html = (first_paragraph_from(html_arg) || html_arg).to_s
|
||||
PrettyText.format_for_email(html).html_safe
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe UserNotificationsHelper do
|
||||
describe 'email_excerpt' do
|
||||
let(:paragraphs) { [
|
||||
"<p>This is the first paragraph, but you should read more.</p>",
|
||||
"<p>And here is its friend, the second paragraph.</p>"
|
||||
] }
|
||||
|
||||
let(:cooked) do
|
||||
paragraphs.join("\n")
|
||||
end
|
||||
|
||||
it "can return the first paragraph" do
|
||||
SiteSetting.digest_min_excerpt_length = 50
|
||||
expect(helper.email_excerpt(cooked)).to eq(paragraphs[0])
|
||||
end
|
||||
|
||||
it "can return another paragraph to satisfy digest_min_excerpt_length" do
|
||||
SiteSetting.digest_min_excerpt_length = 100
|
||||
expect(helper.email_excerpt(cooked)).to eq(paragraphs.join)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue