@@ -39,7 +39,49 @@ defmodule GroupherServer.Test.Delivery.Notification do
3939 |> Repo . update ( )
4040 end
4141
42- describe "notification curd" do
42+ describe "account follow" do
43+ @ tag :wip
44+ test "support follow action" , ~m( user user2) a do
45+ notify_attrs = % {
46+ action: :follow ,
47+ user_id: user . id
48+ }
49+
50+ { :ok , _ } = Delivery . send ( :notify , notify_attrs , user2 )
51+
52+ { :ok , paged_notifies } = Delivery . fetch ( :notification , user . id , % { page: 1 , size: 10 } )
53+
54+ assert paged_notifies . total_count == 1
55+ notify = paged_notifies . entries |> List . first ( )
56+
57+ assert notify . action == "FOLLOW"
58+ assert notify . user_id == user . id
59+ assert user2 |> user_exist_in? ( notify . from_users )
60+ end
61+
62+ @ tag :wip
63+ test "similar follow notify should be merged" , ~m( user user2 user3) a do
64+ notify_attrs = % {
65+ action: :follow ,
66+ user_id: user . id
67+ }
68+
69+ { :ok , _ } = Delivery . send ( :notify , notify_attrs , user2 )
70+ { :ok , _ } = Delivery . send ( :notify , notify_attrs , user3 )
71+
72+ { :ok , paged_notifies } = Delivery . fetch ( :notification , user . id , % { page: 1 , size: 10 } )
73+
74+ notify = paged_notifies . entries |> List . first ( )
75+
76+ assert paged_notifies . total_count == 1
77+
78+ assert notify . from_users |> length == 2
79+ assert user2 |> user_exist_in? ( notify . from_users )
80+ assert user3 |> user_exist_in? ( notify . from_users )
81+ end
82+ end
83+
84+ describe "notification" do
4385 test "similar notify should be merged" , ~m( user user2 user3 notify_attrs) a do
4486 { :ok , _ } = Delivery . send ( :notify , notify_attrs , user2 )
4587 { :ok , _ } = Delivery . send ( :notify , notify_attrs , user3 )
0 commit comments