diff --git a/app/models/seat.rb b/app/models/seat.rb index 7fda5ef2..d33873ed 100644 --- a/app/models/seat.rb +++ b/app/models/seat.rb @@ -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 diff --git a/spec/features/bots/add_bot_players_spec.rb b/spec/features/bots/add_bot_players_spec.rb index 1e7fbceb..70d5c8da 100644 --- a/spec/features/bots/add_bot_players_spec.rb +++ b/spec/features/bots/add_bot_players_spec.rb @@ -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