Merge branch 'birth-dates' into 'develop'
Birth dates See merge request pleroma/pleroma!3608
This commit is contained in:
commit
dd7977bb68
26 changed files with 423 additions and 14 deletions
|
|
@ -755,6 +755,54 @@ defmodule Pleroma.UserTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "user registration, with :birthday_required and :birthday_min_age" do
|
||||
@full_user_data %{
|
||||
bio: "A guy",
|
||||
name: "my name",
|
||||
nickname: "nick",
|
||||
password: "test",
|
||||
password_confirmation: "test",
|
||||
email: "email@example.com"
|
||||
}
|
||||
|
||||
setup do
|
||||
clear_config([:instance, :birthday_required], true)
|
||||
clear_config([:instance, :birthday_min_age], 18 * 365)
|
||||
end
|
||||
|
||||
test "it passes when correct birth date is provided" do
|
||||
today = Date.utc_today()
|
||||
birthday = Date.add(today, -19 * 365)
|
||||
|
||||
params =
|
||||
@full_user_data
|
||||
|> Map.put(:birthday, birthday)
|
||||
|
||||
changeset = User.register_changeset(%User{}, params)
|
||||
|
||||
assert changeset.valid?
|
||||
end
|
||||
|
||||
test "it fails when birth date is not provided" do
|
||||
changeset = User.register_changeset(%User{}, @full_user_data)
|
||||
|
||||
refute changeset.valid?
|
||||
end
|
||||
|
||||
test "it fails when provided invalid birth date" do
|
||||
today = Date.utc_today()
|
||||
birthday = Date.add(today, -17 * 365)
|
||||
|
||||
params =
|
||||
@full_user_data
|
||||
|> Map.put(:birthday, birthday)
|
||||
|
||||
changeset = User.register_changeset(%User{}, params)
|
||||
|
||||
refute changeset.valid?
|
||||
end
|
||||
end
|
||||
|
||||
describe "get_or_fetch/1" do
|
||||
test "gets an existing user by nickname" do
|
||||
user = insert(:user)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue