Merge branch 'fix-tests' into 'master'
Fix tests Closes #390 See merge request framasoft/mobilizon!730
This commit is contained in:
commit
ac112b64c2
@ -145,7 +145,6 @@ defmodule Mobilizon.Service.Notifications.Scheduler do
|
|||||||
with %Actor{user_id: user_id} when not is_nil(user_id) <-
|
with %Actor{user_id: user_id} when not is_nil(user_id) <-
|
||||||
Actors.get_actor(organizer_actor_id),
|
Actors.get_actor(organizer_actor_id),
|
||||||
%User{
|
%User{
|
||||||
locale: locale,
|
|
||||||
settings: %Setting{
|
settings: %Setting{
|
||||||
notification_pending_participation: notification_pending_participation,
|
notification_pending_participation: notification_pending_participation,
|
||||||
timezone: timezone
|
timezone: timezone
|
||||||
@ -160,7 +159,7 @@ defmodule Mobilizon.Service.Notifications.Scheduler do
|
|||||||
:direct
|
:direct
|
||||||
|
|
||||||
:one_day ->
|
:one_day ->
|
||||||
calculate_next_day_notification(Date.utc_today(), timezone, locale)
|
calculate_next_day_notification(Date.utc_today(), timezone)
|
||||||
|
|
||||||
:one_hour ->
|
:one_hour ->
|
||||||
DateTime.utc_now()
|
DateTime.utc_now()
|
||||||
@ -219,7 +218,6 @@ defmodule Mobilizon.Service.Notifications.Scheduler do
|
|||||||
defp pending_membership_admin_notification_user(
|
defp pending_membership_admin_notification_user(
|
||||||
%User{
|
%User{
|
||||||
id: user_id,
|
id: user_id,
|
||||||
locale: locale,
|
|
||||||
settings: %Setting{
|
settings: %Setting{
|
||||||
notification_pending_membership: notification_pending_membership,
|
notification_pending_membership: notification_pending_membership,
|
||||||
timezone: timezone
|
timezone: timezone
|
||||||
@ -236,7 +234,7 @@ defmodule Mobilizon.Service.Notifications.Scheduler do
|
|||||||
:direct
|
:direct
|
||||||
|
|
||||||
:one_day ->
|
:one_day ->
|
||||||
calculate_next_day_notification(Date.utc_today(), timezone, locale)
|
calculate_next_day_notification(Date.utc_today(), timezone)
|
||||||
|
|
||||||
:one_hour ->
|
:one_hour ->
|
||||||
DateTime.utc_now()
|
DateTime.utc_now()
|
||||||
@ -280,13 +278,12 @@ defmodule Mobilizon.Service.Notifications.Scheduler do
|
|||||||
else: calculate_first_day_of_week(Date.add(date, -1), locale)
|
else: calculate_first_day_of_week(Date.add(date, -1), locale)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp calculate_next_day_notification(%Date{} = day, timezone, locale) do
|
defp calculate_next_day_notification(%Date{} = day, timezone) do
|
||||||
send_at = date_to_datetime(day, ~T[18:00:00], timezone)
|
send_at = date_to_datetime(day, ~T[18:00:00], timezone)
|
||||||
|
|
||||||
if DateTime.compare(send_at, DateTime.utc_now()) == :lt do
|
if DateTime.compare(send_at, DateTime.utc_now()) == :lt do
|
||||||
day
|
day
|
||||||
|> Date.add(1)
|
|> Date.add(1)
|
||||||
|> calculate_first_day_of_week(locale)
|
|
||||||
|> date_to_datetime(~T[18:00:00], timezone)
|
|> date_to_datetime(~T[18:00:00], timezone)
|
||||||
else
|
else
|
||||||
send_at
|
send_at
|
||||||
|
@ -155,6 +155,7 @@ defmodule Mobilizon.Web.Resolvers.GroupTest do
|
|||||||
group.preferred_username
|
group.preferred_username
|
||||||
|
|
||||||
assert res["data"]["group"]["members"]["total"] == 2
|
assert res["data"]["group"]["members"]["total"] == 2
|
||||||
|
assert res["data"]["group"]["members"]["elements"] == []
|
||||||
|
|
||||||
res =
|
res =
|
||||||
conn
|
conn
|
||||||
@ -170,9 +171,12 @@ defmodule Mobilizon.Web.Resolvers.GroupTest do
|
|||||||
assert res["errors"] == nil
|
assert res["errors"] == nil
|
||||||
|
|
||||||
assert res["data"]["group"]["members"]["total"] == 2
|
assert res["data"]["group"]["members"]["total"] == 2
|
||||||
assert hd(res["data"]["group"]["members"]["elements"])["role"] == "ADMINISTRATOR"
|
|
||||||
|
|
||||||
assert hd(res["data"]["group"]["members"]["elements"])["actor"]["preferredUsername"] ==
|
admin =
|
||||||
|
res["data"]["group"]["members"]["elements"]
|
||||||
|
|> Enum.find(&(&1["role"] == "ADMINISTRATOR"))
|
||||||
|
|
||||||
|
assert admin["actor"]["preferredUsername"] ==
|
||||||
actor.preferred_username
|
actor.preferred_username
|
||||||
|
|
||||||
res =
|
res =
|
||||||
|
@ -249,7 +249,15 @@ defmodule Mobilizon.Service.Notifications.SchedulerTest do
|
|||||||
|
|
||||||
Scheduler.pending_participation_notification(event)
|
Scheduler.pending_participation_notification(event)
|
||||||
|
|
||||||
{:ok, scheduled_at} = NaiveDateTime.new(Date.utc_today(), ~T[18:00:00])
|
now = Time.utc_now()
|
||||||
|
|
||||||
|
{:ok, scheduled_at} =
|
||||||
|
if now.hour <= 18 do
|
||||||
|
NaiveDateTime.new(Date.utc_today(), ~T[18:00:00])
|
||||||
|
else
|
||||||
|
Date.utc_today() |> Date.add(1) |> NaiveDateTime.new(~T[18:00:00])
|
||||||
|
end
|
||||||
|
|
||||||
{:ok, scheduled_at} = DateTime.from_naive(scheduled_at, "Europe/Paris")
|
{:ok, scheduled_at} = DateTime.from_naive(scheduled_at, "Europe/Paris")
|
||||||
|
|
||||||
assert_enqueued(
|
assert_enqueued(
|
||||||
|
Loading…
Reference in New Issue
Block a user