add additional database table connecting game matches to participating players
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user