mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-02 09:45:13 +00:00
98cb255d12
OTP builds to 1.15
Changelog entry
Ensure policies are fully loaded
Fix :warn
use main branch for linkify
Fix warn in tests
Migrations for phoenix 1.17
Revert "Migrations for phoenix 1.17"
This reverts commit 6a3b2f15b7
.
Oban upgrade
Add default empty whitelist
mix format
limit test to amd64
OTP 26 tests for 1.15
use OTP_VERSION tag
baka
just 1.15
Massive deps update
Update locale, deps
Mix format
shell????
multiline???
?
max cases 1
use assert_recieve
don't put_env in async tests
don't async conn/fs tests
mix format
FIx some uploader issues
Fix tests
59 lines
1.6 KiB
Elixir
59 lines
1.6 KiB
Elixir
# Pleroma: A lightweight social networking server
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
defmodule Pleroma.Web.Plugs.UserTrackingPlugTest do
|
|
use Pleroma.Web.ConnCase, async: false
|
|
|
|
import Pleroma.Factory
|
|
|
|
alias Pleroma.Web.Plugs.UserTrackingPlug
|
|
|
|
test "updates last_active_at for a new user", %{conn: conn} do
|
|
user = insert(:user)
|
|
|
|
assert is_nil(user.last_active_at)
|
|
|
|
test_started_at = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
|
|
|
%{assigns: %{user: user}} =
|
|
conn
|
|
|> assign(:user, user)
|
|
|> UserTrackingPlug.call(%{})
|
|
|
|
assert user.last_active_at >= test_started_at
|
|
assert user.last_active_at <= NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second)
|
|
end
|
|
|
|
test "doesn't update last_active_at if it was updated recently", %{conn: conn} do
|
|
last_active_at =
|
|
NaiveDateTime.utc_now()
|
|
|> NaiveDateTime.add(-:timer.hours(1), :millisecond)
|
|
|> NaiveDateTime.truncate(:second)
|
|
|
|
user = insert(:user, %{last_active_at: last_active_at})
|
|
|
|
%{assigns: %{user: user}} =
|
|
conn
|
|
|> assign(:user, user)
|
|
|> UserTrackingPlug.call(%{})
|
|
|
|
assert user.last_active_at == last_active_at
|
|
end
|
|
|
|
test "skips updating last_active_at if user ID is nil", %{conn: conn} do
|
|
%{assigns: %{user: user}} =
|
|
conn
|
|
|> assign(:user, %Pleroma.User{})
|
|
|> UserTrackingPlug.call(%{})
|
|
|
|
assert is_nil(user.last_active_at)
|
|
end
|
|
|
|
test "does nothing if user is not present", %{conn: conn} do
|
|
%{assigns: assigns} = UserTrackingPlug.call(conn, %{})
|
|
|
|
refute Map.has_key?(assigns, :user)
|
|
end
|
|
end
|