Add Bot button respects seat occupied status

This commit is contained in:
Jesse C. Fisher 2021-11-10 21:24:15 -08:00
parent 54b2e4bec6
commit 69e8e06975
2 changed files with 4 additions and 6 deletions

View File

@ -45,7 +45,7 @@ class Seat < ActiveRecord::Base
def add_bot
if self.occupied?
return self
return "Failed to add Bot seat full"
else
# self.reload
if self.player == nil
@ -62,7 +62,7 @@ class Seat < ActiveRecord::Base
end
def occupied?
self.user_id.present? || self.user_soft_token.present?
self.user_id.present? || self.user_soft_token.present? || self.try("player").try("is_bot?")
end
def occupied_by? user

View File

@ -18,14 +18,12 @@ feature 'Add bot', type: :feature do
scenario 'visitor can not add a bot if the seat is occupied by bot' do
@button = page.find_button('+ Bot', match: :first).click
@button = page.find_button('+ Bot', match: :first).click
expect(page).to have_content "Failed to add Bot"
page.assert_selector('button', text: '+ Bot', count: 3)
end
scenario 'visitor can not add a bot if the seat is occupied by visitor' do
@button = page.find_button('Sit', match: :first).click
@button = page.find_button('+ Bot', match: :first).click
expect(page).to have_content "Failed to add Bot"
page.assert_selector('button', text: '+ Bot', count: 3)
end
scenario 'user can add a bot if the table is not full' do