Add Bot button respects seat occupied status
This commit is contained in:
parent
d53ecef3f4
commit
44a540cbe8
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user