test fixes

This commit is contained in:
Alexander Strizhakov 2020-06-17 12:34:27 +03:00
parent 028a241b7d
commit 818f3c2393
No known key found for this signature in database
GPG Key ID: 022896A53AEF1381
2 changed files with 31 additions and 33 deletions

View File

@ -332,7 +332,7 @@ test "it doesn't create notifications if content matches with an irreversible fi
User.subscribe(subscriber, user)
insert(:filter, user: subscriber, phrase: "cofe", hide: true)
{:ok, status} = CommonAPI.post(user, %{"status" => "got cofe?"})
{:ok, status} = CommonAPI.post(user, %{status: "got cofe?"})
assert {:ok, []} == Notification.create_notifications(status)
end
@ -344,7 +344,7 @@ test "it creates notifications if content matches with a not irreversible filter
User.subscribe(subscriber, user)
insert(:filter, user: subscriber, phrase: "cofe", hide: false)
{:ok, status} = CommonAPI.post(user, %{"status" => "got cofe?"})
{:ok, status} = CommonAPI.post(user, %{status: "got cofe?"})
{:ok, [notification]} = Notification.create_notifications(status)
assert notification
@ -355,7 +355,7 @@ test "it creates notifications when someone likes user's status with a filtered
other_user = insert(:user)
insert(:filter, user: user, phrase: "tesla", hide: true)
{:ok, activity_one} = CommonAPI.post(user, %{"status" => "wow tesla"})
{:ok, activity_one} = CommonAPI.post(user, %{status: "wow tesla"})
{:ok, activity_two} = CommonAPI.favorite(other_user, activity_one.id)
{:ok, [notification]} = Notification.create_notifications(activity_two)
@ -1137,8 +1137,7 @@ test "it doesn't return notifications about mentions with filtered word", %{user
insert(:filter, user: user, phrase: "cofe", hide: true)
another_user = insert(:user)
{:ok, _activity} =
CommonAPI.post(another_user, %{"status" => "@#{user.nickname} got cofe?"})
{:ok, _activity} = CommonAPI.post(another_user, %{status: "@#{user.nickname} got cofe?"})
assert Enum.empty?(Notification.for_user(user))
end
@ -1147,7 +1146,7 @@ test "it returns notifications about mentions with not hidden filtered word", %{
insert(:filter, user: user, phrase: "test", hide: false)
another_user = insert(:user)
{:ok, _} = CommonAPI.post(another_user, %{"status" => "@#{user.nickname} test"})
{:ok, _} = CommonAPI.post(another_user, %{status: "@#{user.nickname} test"})
assert length(Notification.for_user(user)) == 1
end
@ -1156,7 +1155,7 @@ test "it returns notifications about favorites with filtered word", %{user: user
insert(:filter, user: user, phrase: "cofe", hide: true)
another_user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{"status" => "Give me my cofe!"})
{:ok, activity} = CommonAPI.post(user, %{status: "Give me my cofe!"})
{:ok, _} = CommonAPI.favorite(another_user, activity.id)
assert length(Notification.for_user(user)) == 1

View File

@ -513,22 +513,21 @@ test "doesn't return activities with filtered words" do
user_two = insert(:user)
insert(:filter, user: user, phrase: "test", hide: true)
{:ok, %{id: id1, data: %{"context" => context}}} = CommonAPI.post(user, %{"status" => "1"})
{:ok, %{id: id1, data: %{"context" => context}}} = CommonAPI.post(user, %{status: "1"})
{:ok, %{id: id2}} =
CommonAPI.post(user_two, %{"status" => "2", "in_reply_to_status_id" => id1})
{:ok, %{id: id2}} = CommonAPI.post(user_two, %{status: "2", in_reply_to_status_id: id1})
{:ok, %{id: id3} = user_activity} =
CommonAPI.post(user, %{"status" => "3 test?", "in_reply_to_status_id" => id2})
CommonAPI.post(user, %{status: "3 test?", in_reply_to_status_id: id2})
{:ok, %{id: id4} = filtered_activity} =
CommonAPI.post(user_two, %{"status" => "4 test!", "in_reply_to_status_id" => id3})
CommonAPI.post(user_two, %{status: "4 test!", in_reply_to_status_id: id3})
{:ok, _} = CommonAPI.post(user, %{"status" => "5", "in_reply_to_status_id" => id4})
{:ok, _} = CommonAPI.post(user, %{status: "5", in_reply_to_status_id: id4})
activities =
context
|> ActivityPub.fetch_activities_for_context(%{"user" => user})
|> ActivityPub.fetch_activities_for_context(%{user: user})
|> Enum.map(& &1.id)
assert length(activities) == 4
@ -823,8 +822,8 @@ test "excludes reblogs on request" do
insert(:filter, user: user_two, phrase: "test", hide: false)
params = %{
"type" => ["Create", "Announce"],
"user" => user_two
type: ["Create", "Announce"],
user: user_two
}
{:ok, %{user: user, user_two: user_two, params: params}}
@ -834,12 +833,12 @@ test "it returns statuses if they don't contain exact filter words", %{
user: user,
params: params
} do
{:ok, _} = CommonAPI.post(user, %{"status" => "hey"})
{:ok, _} = CommonAPI.post(user, %{"status" => "got cofefe?"})
{:ok, _} = CommonAPI.post(user, %{"status" => "I am not a boomer"})
{:ok, _} = CommonAPI.post(user, %{"status" => "ok boomers"})
{:ok, _} = CommonAPI.post(user, %{"status" => "ccofee is not a word"})
{:ok, _} = CommonAPI.post(user, %{"status" => "this is a test"})
{:ok, _} = CommonAPI.post(user, %{status: "hey"})
{:ok, _} = CommonAPI.post(user, %{status: "got cofefe?"})
{:ok, _} = CommonAPI.post(user, %{status: "I am not a boomer"})
{:ok, _} = CommonAPI.post(user, %{status: "ok boomers"})
{:ok, _} = CommonAPI.post(user, %{status: "ccofee is not a word"})
{:ok, _} = CommonAPI.post(user, %{status: "this is a test"})
activities = ActivityPub.fetch_activities([], params)
@ -847,8 +846,8 @@ test "it returns statuses if they don't contain exact filter words", %{
end
test "it does not filter user's own statuses", %{user_two: user_two, params: params} do
{:ok, _} = CommonAPI.post(user_two, %{"status" => "Give me some cofe!"})
{:ok, _} = CommonAPI.post(user_two, %{"status" => "ok boomer"})
{:ok, _} = CommonAPI.post(user_two, %{status: "Give me some cofe!"})
{:ok, _} = CommonAPI.post(user_two, %{status: "ok boomer"})
activities = ActivityPub.fetch_activities([], params)
@ -856,11 +855,11 @@ test "it does not filter user's own statuses", %{user_two: user_two, params: par
end
test "it excludes statuses with filter words", %{user: user, params: params} do
{:ok, _} = CommonAPI.post(user, %{"status" => "Give me some cofe!"})
{:ok, _} = CommonAPI.post(user, %{"status" => "ok boomer"})
{:ok, _} = CommonAPI.post(user, %{"status" => "is it a cOfE?"})
{:ok, _} = CommonAPI.post(user, %{"status" => "cofe is all I need"})
{:ok, _} = CommonAPI.post(user, %{"status" => "— ok BOOMER\n"})
{:ok, _} = CommonAPI.post(user, %{status: "Give me some cofe!"})
{:ok, _} = CommonAPI.post(user, %{status: "ok boomer"})
{:ok, _} = CommonAPI.post(user, %{status: "is it a cOfE?"})
{:ok, _} = CommonAPI.post(user, %{status: "cofe is all I need"})
{:ok, _} = CommonAPI.post(user, %{status: "— ok BOOMER\n"})
activities = ActivityPub.fetch_activities([], params)
@ -869,13 +868,13 @@ test "it excludes statuses with filter words", %{user: user, params: params} do
test "it returns all statuses if user does not have any filters" do
another_user = insert(:user)
{:ok, _} = CommonAPI.post(another_user, %{"status" => "got cofe?"})
{:ok, _} = CommonAPI.post(another_user, %{"status" => "test!"})
{:ok, _} = CommonAPI.post(another_user, %{status: "got cofe?"})
{:ok, _} = CommonAPI.post(another_user, %{status: "test!"})
activities =
ActivityPub.fetch_activities([], %{
"type" => ["Create", "Announce"],
"user" => another_user
type: ["Create", "Announce"],
user: another_user
})
assert Enum.count(activities) == 2