Hide comments when allegations phase is closed

Co-Authored-By: Julian Nicolas Herrero <microweb10@gmail.com>
Co-Authored-By: Javi Martín <javim@elretirao.net>
This commit is contained in:
decabeza
2022-07-20 17:23:41 +02:00
committed by Javi Martín
parent 711e6c16eb
commit 5b97e85dd7
3 changed files with 45 additions and 0 deletions

View File

@@ -41,6 +41,28 @@ describe CommentsController do
end.not_to change { question.reload.comments_count }
end
it "does not create an annotation comment if the allegations phase is closed" do
process = create(:legislation_process,
allegations_start_date: 2.days.from_now,
allegations_end_date: 1.month.from_now)
version = create(:legislation_draft_version, process: process)
annotation = create(:legislation_annotation, draft_version: version, text: "One annotation")
sign_in user
expect do
post :create, xhr: true,
params: {
comment: {
commentable_id: annotation.id,
commentable_type: "Legislation::Annotation",
body: "a comment"
}
}
end.not_to change { annotation.reload.comments_count }
end
it "does not create a comment for unverified users when the commentable requires it" do
sign_in unverified_user