summaryrefslogtreecommitdiff
path: root/test/web/common_api/common_api_utils_test.exs
diff options
context:
space:
mode:
authorlambda <lain@soykaf.club>2019-04-02 14:18:23 +0000
committerlambda <lain@soykaf.club>2019-04-02 14:18:23 +0000
commit256b492a5855c09f45af0325a9e9cd2508c88366 (patch)
treef88f28e5fbc2c85dfd106ec9dceb1394588db1a0 /test/web/common_api/common_api_utils_test.exs
parenta79ce94dd4f0b6435ec2aaba5d8867984b491664 (diff)
parent3db923515057b7da23e4bb58a1696cd14df7ed52 (diff)
downloadpleroma-256b492a5855c09f45af0325a9e9cd2508c88366.tar.gz
pleroma-256b492a5855c09f45af0325a9e9cd2508c88366.zip
Merge branch 'bugfix/wrong-date-format' into 'develop'
Support activities with dates in the Unix timestamp format Closes #763 See merge request pleroma/pleroma!1004
Diffstat (limited to 'test/web/common_api/common_api_utils_test.exs')
-rw-r--r--test/web/common_api/common_api_utils_test.exs36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/web/common_api/common_api_utils_test.exs b/test/web/common_api/common_api_utils_test.exs
index e04b9f9b5..f0c59d5c3 100644
--- a/test/web/common_api/common_api_utils_test.exs
+++ b/test/web/common_api/common_api_utils_test.exs
@@ -153,4 +153,40 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
assert conversation_id == object.id
end
end
+
+ describe "formats date to asctime" do
+ test "when date is in ISO 8601 format" do
+ date = DateTime.utc_now() |> DateTime.to_iso8601()
+
+ expected =
+ date
+ |> DateTime.from_iso8601()
+ |> elem(1)
+ |> Calendar.Strftime.strftime!("%a %b %d %H:%M:%S %z %Y")
+
+ assert Utils.date_to_asctime(date) == expected
+ end
+
+ test "when date is a binary in wrong format" do
+ date = DateTime.utc_now()
+
+ expected = ""
+
+ assert Utils.date_to_asctime(date) == expected
+ end
+
+ test "when date is a Unix timestamp" do
+ date = DateTime.utc_now() |> DateTime.to_unix()
+
+ expected = ""
+
+ assert Utils.date_to_asctime(date) == expected
+ end
+
+ test "when date is nil" do
+ expected = ""
+
+ assert Utils.date_to_asctime(nil) == expected
+ end
+ end
end