Do not call LanguageDetector when not language is provided
Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
parent
d7f9d30b2c
commit
3b74d13147
2 changed files with 37 additions and 6 deletions
|
|
@ -9,6 +9,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest
|
|||
alias Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidator
|
||||
alias Pleroma.Web.ActivityPub.Utils
|
||||
|
||||
import Mock
|
||||
import Pleroma.Factory
|
||||
|
||||
describe "Notes" do
|
||||
|
|
@ -234,6 +235,28 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest
|
|||
assert object.language == "pl"
|
||||
end
|
||||
|
||||
test_with_mock "it doesn't call LanguageDetector when language is specified",
|
||||
Pleroma.Language.LanguageDetector,
|
||||
detect: fn _ -> nil end do
|
||||
user = insert(:user)
|
||||
|
||||
note = %{
|
||||
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
"cc" => [],
|
||||
"id" => Utils.generate_object_id(),
|
||||
"type" => "Note",
|
||||
"content" => "a post in English",
|
||||
"contentMap" => %{
|
||||
"en" => "a post in English"
|
||||
},
|
||||
"attributedTo" => user.ap_id
|
||||
}
|
||||
|
||||
ArticleNotePageValidator.cast_and_apply(note)
|
||||
|
||||
refute called(Pleroma.Language.LanguageDetector.detect(:_))
|
||||
end
|
||||
|
||||
test "it adds contentMap if language is specified" do
|
||||
user = insert(:user)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue