@@ -670,7 +670,6 @@ defmodule GroupherServer.Test.CMS.Comments.PostComment do
670670 end
671671
672672 describe "[article comment qa type]" do
673- @ tag :wip2
674673 test "create comment for normal post should have default qa flags" , ~m( user community) a do
675674 post_attrs = mock_attrs ( :post , % { community_id: community . id } )
676675 { :ok , post } = CMS . create_article ( community , :post , post_attrs , user )
@@ -680,7 +679,6 @@ defmodule GroupherServer.Test.CMS.Comments.PostComment do
680679 assert not post_comment . is_solution
681680 end
682681
683- @ tag :wip2
684682 test "create comment for question post should have flags" , ~m( user community) a do
685683 post_attrs = mock_attrs ( :post , % { community_id: community . id , is_question: true } )
686684 { :ok , post } = CMS . create_article ( community , :post , post_attrs , user )
@@ -690,7 +688,6 @@ defmodule GroupherServer.Test.CMS.Comments.PostComment do
690688 assert post_comment . is_for_question
691689 end
692690
693- @ tag :wip2
694691 test "update comment with is_question should batch update exsit comments is_for_question field" ,
695692 ~m( user community) a do
696693 post_attrs = mock_attrs ( :post , % { community_id: community . id , is_question: true } )
@@ -714,7 +711,6 @@ defmodule GroupherServer.Test.CMS.Comments.PostComment do
714711 assert not comment3 . is_for_question
715712 end
716713
717- @ tag :wip2
718714 test "can mark a comment as solution" , ~m( user community) a do
719715 post_attrs = mock_attrs ( :post , % { community_id: community . id , is_question: true } )
720716 { :ok , post } = CMS . create_article ( community , :post , post_attrs , user )
@@ -732,7 +728,6 @@ defmodule GroupherServer.Test.CMS.Comments.PostComment do
732728 assert post . solution_digest == comment . body_html
733729 end
734730
735- @ tag :wip2
736731 test "non-post-author can not mark a comment as solution" , ~m( user community) a do
737732 post_attrs = mock_attrs ( :post , % { community_id: community . id , is_question: true } )
738733 { :ok , post } = CMS . create_article ( community , :post , post_attrs , user )
@@ -747,7 +742,6 @@ defmodule GroupherServer.Test.CMS.Comments.PostComment do
747742 reason |> is_error? ( :require_questioner )
748743 end
749744
750- @ tag :wip2
751745 test "can undo mark a comment as solution" , ~m( user community) a do
752746 post_attrs = mock_attrs ( :post , % { community_id: community . id , is_question: true } )
753747 { :ok , post } = CMS . create_article ( community , :post , post_attrs , user )
@@ -765,7 +759,6 @@ defmodule GroupherServer.Test.CMS.Comments.PostComment do
765759 assert not post . is_solved
766760 end
767761
768- @ tag :wip2
769762 test "non-post-author can not undo mark a comment as solution" , ~m( user community) a do
770763 post_attrs = mock_attrs ( :post , % { community_id: community . id , is_question: true } )
771764 { :ok , post } = CMS . create_article ( community , :post , post_attrs , user )
@@ -780,7 +773,6 @@ defmodule GroupherServer.Test.CMS.Comments.PostComment do
780773 reason |> is_error? ( :require_questioner )
781774 end
782775
783- @ tag :wip2
784776 test "can only mark one best comment as solution" , ~m( user community) a do
785777 post_attrs = mock_attrs ( :post , % { community_id: community . id , is_question: true } )
786778 { :ok , post } = CMS . create_article ( community , :post , post_attrs , user )
@@ -801,5 +793,23 @@ defmodule GroupherServer.Test.CMS.Comments.PostComment do
801793 assert answers |> length == 1
802794 assert answers |> List . first ( ) |> Map . get ( :id ) == comment2 . id
803795 end
796+
797+ test "update a solution should also update post's solution digest" , ~m( user community) a do
798+ post_attrs = mock_attrs ( :post , % { community_id: community . id , is_question: true } )
799+ { :ok , post } = CMS . create_article ( community , :post , post_attrs , user )
800+
801+ { :ok , post } = ORM . find ( Post , post . id , preload: [ author: :user ] )
802+ post_author = post . author . user
803+
804+ { :ok , comment } = CMS . create_article_comment ( :post , post . id , "solution" , post_author )
805+ { :ok , comment } = CMS . mark_comment_solution ( comment . id , post_author )
806+
807+ { :ok , post } = ORM . find ( Post , post . id , preload: [ author: :user ] )
808+ assert post . solution_digest == "solution"
809+
810+ { :ok , _comment } = CMS . update_article_comment ( comment , "new solution" )
811+ { :ok , post } = ORM . find ( Post , post . id , preload: [ author: :user ] )
812+ assert post . solution_digest == "new solution"
813+ end
804814 end
805815end
0 commit comments