Add WIP gather spec

This commit is contained in:
Ari Timonen 2020-04-19 06:13:39 +03:00
parent 0ea0bca438
commit 54dec5685f
2 changed files with 50 additions and 28 deletions

View file

@ -45,7 +45,7 @@ class GatherersController < ApplicationController
@gatherer.update_attribute(:status, states[params[:status]])
end
render :nothing => true, :status => 200
render body: nil, :status => 200
end
def destroy

View file

@ -4,34 +4,56 @@ feature 'Gathers', js: true do
let!(:user) { create :user }
let!(:gather) { create :gather, :running }
feature 'Shoutbox' do
background do
sign_in_as user
end
background do
sign_in_as user
end
scenario 'create shout' do
visit gather_path(gather)
shout = rand(100000).to_s
fill_in "shout_Gather_#{gather.id}_text", with: shout
click_button 'Shout!'
expect(page).to have_content(shout)
end
scenario 'Try to join without checking TOS' do
visit gather_path(gather)
scenario 'enter more than 100 characters' do
valid_shout = 100.times.map { "a" }.join
invalid_shout = 101.times.map { "a" }.join
visit gather_path(gather)
expect(page).to_not have_content("Maximum shout length exceeded")
fill_in "shout_Gather_#{gather.id}_text", with: invalid_shout
expect(page).to have_content("Maximum shout length exceeded")
fill_in "shout_Gather_#{gather.id}_text", with: valid_shout
expect(page).to_not have_content("Maximum shout length exceeded")
end
find('a#gatherJoinBtn').trigger('click')
scenario 'creating shout while banned' do
Ban.create! ban_type: Ban::TYPE_MUTE, expiry: Time.now + 10.days, user_name: user.username
visit root_path
expect(find("#sidebar")).to have_content "You have been muted."
end
end
# TODO: check error
expect(page).to have_content("Confirm must be accepted")
expect(gather.gatherers.count).to eq(0)
end
scenario 'Join (1 player)' do
visit gather_path(gather)
check 'gatherer[confirm]'
find('a#gatherJoinBtn').trigger('click')
expect(page).to have_content(I18n.t(:gathers_join))
expect(gather.gatherers.count).to eq(1)
expect(gather.gatherers.last.user_id).to eq(user.id)
end
# NOTE: this might break due to afk kicker
scenario 'Join (12 players)' do
sign_out
expect(gather.status).to eq(Gather::STATE_RUNNING)
users = create_list(:user, 11)
users << user
users.each do |u|
sign_in_as u
visit gather_path(gather)
check 'gatherer[confirm]'
find('a#gatherJoinBtn').trigger('click')
expect(page).to have_content(I18n.t(:gathers_join))
expect(gather.gatherers.last.user_id).to eq(u.id)
sign_out
end
expect(gather.gatherers.count).to eq(12)
# expect(gather.status).to eq(Gather::STATE_VOTING)
sign_in_as user
visit gather_path(gather)
# sleep(90)
end
end