@@ -393,6 +393,34 @@ defmodule MastaniServer.Test.Mutation.Post do
393393 assert community2 . id in assoc_communities
394394 end
395395
396+ @ tag :wip
397+ test "when set to multi communiies, the first is the original" do
398+ passport_rules = % { "post.community.set" => true }
399+ rule_conn = simu_conn ( :user , cms: passport_rules )
400+ { :ok , user } = db_insert ( :user )
401+
402+ { :ok , community } = db_insert ( :community )
403+
404+ post_attrs = mock_attrs ( :post , % { community_id: community . id } )
405+ { :ok , post } = CMS . create_content ( community , :post , post_attrs , user )
406+
407+ { :ok , community2 } = db_insert ( :community )
408+ { :ok , community3 } = db_insert ( :community )
409+
410+ variables = % { id: post . id , communityId: community . id }
411+ rule_conn |> mutation_result ( @ set_community_query , variables , "setCommunity" )
412+
413+ variables = % { id: post . id , communityId: community2 . id }
414+ rule_conn |> mutation_result ( @ set_community_query , variables , "setCommunity" )
415+
416+ variables = % { id: post . id , communityId: community3 . id }
417+ rule_conn |> mutation_result ( @ set_community_query , variables , "setCommunity" )
418+
419+ { :ok , found } = ORM . find ( CMS.Post , post . id , preload: :communities )
420+
421+ assert found . communities |> List . first ( ) |> Map . get ( :id ) == community . id
422+ end
423+
396424 @ unset_community_query """
397425 mutation($id: ID!, $communityId: ID!) {
398426 unsetCommunity(id: $id, communityId: $communityId) {
0 commit comments