FIX: elided content in email should always have an href

Not 100% sure why the changes in `PrettyText.format_for_email` raised this issue, but we were missing adding a link to the Discourse instance whenever we are replacing the elided part of a post with a link to either the post or the Discourse instance in the email.

Also reformated the specs using better variable names (sometimes a variable named `md` would contain some html) and used the `match_html` helper for all the tests.
This commit is contained in:
Régis Hanol
2024-05-22 10:42:58 +02:00
parent 8f7a3e5b29
commit d4af30f26d
2 changed files with 47 additions and 29 deletions

View File

@ -37,7 +37,7 @@ after_initialize do
.each do |el|
text = el.css("summary").text
link = fragment.document.create_element("a")
link["href"] = post.url if post
link["href"] = post&.url.presence || Discourse.base_url
link.content = I18n.t("details.excerpt_details")
el.replace CGI.escapeHTML(text) + " " + link.to_html
end