Skip to content

Commit c1b81cb

Browse files
authored
fix: statistics aggregation spec の ID ハードコードを削除 (#1805)
PostgreSQL のシーケンスはトランザクションロールバックで 巻き戻らないため、テスト実行中にシーケンスが積算されると `create(:dojo, id: 194)` の明示的 ID と自動採番が衝突する。 dojo を ID 指定なしで作成し、生成された ID をモックデータに 渡すよう修正して、同様の衝突が将来発生しないようにする。
1 parent 244bea4 commit c1b81cb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

spec/lib/statistics/aggregation_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
create(:dojo_event_service, dojo_id: d1.id, name: :connpass, group_id: 9876)
2323
create(:dojo_event_service, dojo_id: d2.id, name: :doorkeeper, group_id: 5555)
2424

25-
create(:dojo, id: 194, name: 'Dojo194', email: 'info@dojo194.example.com', description: 'CoderDojo194', tags: %w(CoderDojo194), url: 'https://example.com/dojo194', prefecture_id: 13)
25+
d3 = create(:dojo, name: 'Dojo3', email: 'info@dojo3.example.com', description: 'CoderDojo3', tags: %w(CoderDojo3), url: 'https://example.com/dojo3', prefecture_id: 13)
2626
allow(EventService::Providers::StaticYaml).to receive(:new).and_return(yaml_provider)
2727
allow(yaml_provider).to receive(:fetch_events).and_return([
28-
{ 'dojo_id' => 194, 'event_url' => 'https://example.com/event/12345', 'evented_at' => '2023-12-10 14:00', 'participants' => 1 }
28+
{ 'dojo_id' => d3.id, 'event_url' => 'https://example.com/event/12345', 'evented_at' => '2023-12-10 14:00', 'participants' => 1 }
2929
])
3030
end
3131

0 commit comments

Comments
 (0)