Skip to content

Commit 9f8b6b7

Browse files
committed
Update 'with_valid_submitted_results' comp factory
1 parent 43085af commit 9f8b6b7

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

spec/factories/competitions.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,14 @@
294294
rounds.each do |round|
295295
FactoryBot.create(:inbox_result, competition: competition, person_id: person.ref_id, event_id: round.event.id, format_id: round.format.id, round: round)
296296
FactoryBot.create_list(:scramble, 5, competition: competition, event_id: round.event.id, format_id: round.format.id, round: round)
297+
298+
matched_scr_set = FactoryBot.create(:matched_scramble_set, round: round)
299+
matched_scrambles = FactoryBot.build_list(:matched_scramble, 5, matched_scramble_set: matched_scr_set) do |matched_scr, i|
300+
matched_scr.ordered_index = i
301+
end
302+
# When using `create_list`, it tries to create everything with `ordered_index` eq 0
303+
# and THEN passes it to the `do` block, but that's too late because at this point the SQL `UNIQUE` constraint already failed.
304+
matched_scrambles.each(&:save!)
297305
end
298306
end
299307
end

0 commit comments

Comments
 (0)