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.
```
This commit is contained in:
Alan Guo Xiang Tan 2023-07-06 07:30:41 +08:00 committed by GitHub
parent 76f92ba253
commit 7867cc4b03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -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)