require 'rails_helper' describe UserNotificationsHelper do describe 'email_excerpt' do let(:paragraphs) { [ "
This is the first paragraph, but you should read more.
", "And here is its friend, the second paragraph.
" ] } 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 it "doesn't count emoji images" do with_emoji = "Hi
" arg = ([with_emoji] + paragraphs).join("\n") SiteSetting.digest_min_excerpt_length = 50 expect(helper.email_excerpt(arg)).to eq([with_emoji, paragraphs[0]].join) end it "only counts link text" do with_link = "Hi friends!
" arg = ([with_link] + paragraphs).join("\n") SiteSetting.digest_min_excerpt_length = 50 expect(helper.email_excerpt(arg)).to eq([with_link, paragraphs[0]].join) end end end