Merge branch 'html_to_text-nil' into 'main'
fix: allow html_to_text/1 to receive nil, e.g. for empty event descriptions See merge request framasoft/mobilizon!1502
This commit is contained in:
commit
f6ff99987f
|
@ -41,7 +41,9 @@ defmodule Mobilizon.Service.Formatter.HTML do
|
||||||
|
|
||||||
def strip_tags_and_insert_spaces(html), do: html
|
def strip_tags_and_insert_spaces(html), do: html
|
||||||
|
|
||||||
@spec html_to_text(String.t()) :: String.t()
|
@spec html_to_text(String.t() | nil) :: String.t() | nil
|
||||||
|
def html_to_text(nil), do: nil
|
||||||
|
|
||||||
def html_to_text(html) do
|
def html_to_text(html) do
|
||||||
html
|
html
|
||||||
|> String.replace(~r/<li>/, "\\g{1}- ", global: true)
|
|> String.replace(~r/<li>/, "\\g{1}- ", global: true)
|
||||||
|
|
|
@ -44,11 +44,13 @@ defmodule Mobilizon.Service.ICalendarTest do
|
||||||
%Event{} = event = insert(:event, title: "I'm public")
|
%Event{} = event = insert(:event, title: "I'm public")
|
||||||
%Event{} = event2 = insert(:event, visibility: :private, title: "I'm private")
|
%Event{} = event2 = insert(:event, visibility: :private, title: "I'm private")
|
||||||
%Event{} = event3 = insert(:event, title: "Another public")
|
%Event{} = event3 = insert(:event, title: "Another public")
|
||||||
|
%Event{} = event4 = insert(:event, title: "No description", description: nil)
|
||||||
|
|
||||||
{:commit, ics} = ICalendarService.create_cache("instance")
|
{:commit, ics} = ICalendarService.create_cache("instance")
|
||||||
assert ics =~ event.title
|
assert ics =~ event.title
|
||||||
refute ics =~ event2.title
|
refute ics =~ event2.title
|
||||||
assert ics =~ event3.title
|
assert ics =~ event3.title
|
||||||
|
assert ics =~ event4.title
|
||||||
end
|
end
|
||||||
|
|
||||||
test "with 50 events" do
|
test "with 50 events" do
|
||||||
|
|
Loading…
Reference in a new issue