From 7867cc4b0355b060d7392dbd5b2f8fb7d3295db2 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Thu, 6 Jul 2023 07:30:41 +0800 Subject: [PATCH] DEV: Fix incorrect fabrication leading to index violation errors (#488) This was causing the tests to be flaky with the following errors on CI: ``` PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_assignments_on_target_id_and_target_type" DETAIL: Key (target_id, target_type)=(39, Topic) already exists. ``` --- spec/requests/assign_controller_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/requests/assign_controller_spec.rb b/spec/requests/assign_controller_spec.rb index b35df81..35870d2 100644 --- a/spec/requests/assign_controller_spec.rb +++ b/spec/requests/assign_controller_spec.rb @@ -344,17 +344,19 @@ RSpec.describe DiscourseAssign::AssignController do fab!(:assignments) do Fabricate( - :post_assignment, + :topic_assignment, assigned_to: other_allowed_user, target: topic, assigned_by_user: admin, ) + Fabricate( - :topic_assignment, + :post_assignment, assigned_to: other_allowed_user, target: post_in_same_topic, assigned_by_user: admin, ) + Fabricate(:topic_assignment, assigned_to: allowed_user, assigned_by_user: admin) Fabricate(:topic_assignment, assigned_to: other_allowed_user, assigned_by_user: admin)