2015-04-27 22:32:27 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-05-05 21:51:26 +00:00
|
|
|
feature 'Shoutbox', js: true do
|
|
|
|
let!(:user) { create :user }
|
|
|
|
|
2015-04-27 22:32:27 +00:00
|
|
|
background do
|
2015-05-05 21:51:26 +00:00
|
|
|
sign_in_as user
|
2015-04-27 22:32:27 +00:00
|
|
|
end
|
|
|
|
|
2015-05-05 21:51:26 +00:00
|
|
|
scenario 'creating a valid shout' do
|
|
|
|
visit root_path
|
|
|
|
shout = rand(100000).to_s
|
|
|
|
fill_in 'shoutbox_text', with: shout
|
|
|
|
click_button 'Shout!'
|
|
|
|
expect(page).to have_content(shout)
|
|
|
|
end
|
2015-04-27 22:32:27 +00:00
|
|
|
|
2015-05-09 15:21:48 +00:00
|
|
|
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
|
|
|
|
|
2015-05-05 21:51:26 +00:00
|
|
|
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
|
2015-04-27 22:32:27 +00:00
|
|
|
end
|