add additional database table connecting game matches to participating players

This commit is contained in:
2026-11-10 01:04:07 +03:00
parent 271daac935
commit 219448ccfb
10 changed files with 103 additions and 3 deletions
+6
View File
@@ -33,6 +33,12 @@ RSpec.describe Match, type: :model do
expect(match.player2).to eq(player2)
end
it "automatically creates match_player records on creation" do
match = Match.create!(valid_attributes)
expect(match.match_players.pluck(:player_id)).to contain_exactly(player1.id, player2.id)
expect(match.players).to contain_exactly(player1, player2)
end
it "does not allow the same player on both sides" do
match = Match.new(valid_attributes.merge(player2: player1))
expect(match).not_to be_valid