From 200ab27e7a279555dcd73f59d5242adcc83accc8 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 20 Sep 2018 23:49:08 +0000 Subject: [PATCH] test: add test proving that users are refreshed when stale --- test/user_test.exs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/user_test.exs b/test/user_test.exs index 5c61b0930..58fe6eeda 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -166,6 +166,25 @@ test "returns nil for nonexistant local user" do fetched_user = User.get_or_fetch_by_nickname("nonexistant") assert fetched_user == nil end + + test "updates an existing user, if stale" do + a_week_ago = NaiveDateTime.add(NaiveDateTime.utc_now(), -604_800) + + orig_user = + insert( + :user, + local: false, + nickname: "admin@mastodon.example.org", + ap_id: "http://mastodon.example.org/users/admin", + last_refreshed_at: a_week_ago + ) + + assert orig_user.last_refreshed_at == a_week_ago + + user = User.get_or_fetch_by_ap_id("http://mastodon.example.org/users/admin") + + refute user.last_refreshed_at == orig_user.last_refreshed_at + end end test "returns an ap_id for a user" do