content: HTML.filter_tags(object_data["content"]),
text: nil,
created_at: created_at,
+ edited_at: nil,
reblogs_count: 0,
replies_count: 0,
favourites_count: 0,
status = StatusView.render("show.json", activity: visible, for: poster)
assert status.pleroma.parent_visible
end
+
+ test "it shows edited_at" do
+ poster = insert(:user)
+
+ {:ok, post} = CommonAPI.post(poster, %{status: "hey"})
+
+ status = StatusView.render("show.json", activity: post)
+ refute status.edited_at
+
+ {:ok, _} = CommonAPI.update(poster, post, %{status: "mew mew"})
+ edited = Pleroma.Activity.normalize(post)
+
+ status = StatusView.render("show.json", activity: edited)
+ assert status.edited_at
+ end
+
+ test "with a source object" do
+ note =
+ insert(:note,
+ data: %{"source" => %{"content" => "object source", "mediaType" => "text/markdown"}}
+ )
+
+ activity = insert(:note_activity, note: note)
+
+ status = StatusView.render("show.json", activity: activity, with_source: true)
+ assert status.text == "object source"
+ end
+
+ describe "source.json" do
+ test "with a source object, renders both source and content type" do
+ note =
+ insert(:note,
+ data: %{"source" => %{"content" => "object source", "mediaType" => "text/markdown"}}
+ )
+
+ activity = insert(:note_activity, note: note)
+
+ status = StatusView.render("source.json", activity: activity)
+ assert status.text == "object source"
+ assert status.content_type == "text/markdown"
+ end
+
+ test "with a source string, renders source and put text/plain as the content type" do
+ note = insert(:note, data: %{"source" => "string source"})
+ activity = insert(:note_activity, note: note)
+
+ status = StatusView.render("source.json", activity: activity)
+ assert status.text == "string source"
+ assert status.content_type == "text/plain"
+ end
+ end
end