From ae1e2ef833772df093cdce3b3ef90e4f9882b73f Mon Sep 17 00:00:00 2001 From: Ari Timonen Date: Sat, 18 Apr 2020 08:04:23 +0300 Subject: [PATCH] Move gather shoutbox spec --- spec/features/gathers/gathers_shoutbox.rb | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 spec/features/gathers/gathers_shoutbox.rb diff --git a/spec/features/gathers/gathers_shoutbox.rb b/spec/features/gathers/gathers_shoutbox.rb new file mode 100644 index 0000000..9d18acf --- /dev/null +++ b/spec/features/gathers/gathers_shoutbox.rb @@ -0,0 +1,37 @@ +require 'rails_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("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 + + 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 \ No newline at end of file