mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-15 22:30:53 +00:00
Added test for client side shoutbox validation
This commit is contained in:
parent
473d9ea15b
commit
e59f8e3993
2 changed files with 48 additions and 0 deletions
37
spec/features/gathers/gathers_spec.rb
Normal file
37
spec/features/gathers/gathers_spec.rb
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature 'Gathers', js: true do
|
||||||
|
let!(:user) { create :user }
|
||||||
|
let!(:gather) { create :gather, :running }
|
||||||
|
|
||||||
|
feature 'Shoutbox' do
|
||||||
|
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 '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("Shout message length exceeded")
|
||||||
|
fill_in "shout_Gather_#{gather.id}_text", with: invalid_shout
|
||||||
|
expect(page).to have_content("Shout message length exceeded")
|
||||||
|
fill_in "shout_Gather_#{gather.id}_text", with: valid_shout
|
||||||
|
expect(page).to_not have_content("Shout message length exceeded")
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
end
|
|
@ -15,6 +15,17 @@ feature 'Shoutbox', js: true do
|
||||||
expect(page).to have_content(shout)
|
expect(page).to have_content(shout)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario 'enter more than 100 characters' do
|
||||||
|
valid_shout = 100.times.map { "a" }.join
|
||||||
|
invalid_shout = 101.times.map { "a" }.join
|
||||||
|
visit root_path
|
||||||
|
expect(page).to_not have_content("Shout message length exceeded")
|
||||||
|
fill_in 'shoutbox_text', with: invalid_shout
|
||||||
|
expect(page).to have_content("Shout message length exceeded")
|
||||||
|
fill_in 'shoutbox_text', with: valid_shout
|
||||||
|
expect(page).to_not have_content("Shout message length exceeded")
|
||||||
|
end
|
||||||
|
|
||||||
scenario 'creating shout while banned' do
|
scenario 'creating shout while banned' do
|
||||||
Ban.create! ban_type: Ban::TYPE_MUTE, expiry: Time.now + 10.days, user_name: user.username
|
Ban.create! ban_type: Ban::TYPE_MUTE, expiry: Time.now + 10.days, user_name: user.username
|
||||||
visit root_path
|
visit root_path
|
||||||
|
|
Loading…
Reference in a new issue