Merge pull request #11 from cblanc/shoutbox_quick_fix

Shoutbox quick fix
This commit is contained in:
simplefl 2015-04-28 17:46:09 +02:00
commit ce1412282a
6 changed files with 48 additions and 84 deletions

4
.gitignore vendored
View file

@ -3,6 +3,7 @@
/tmp/*
/spec/tmp/*
.ruby-version
.ruby-gemset
.env
.tmp*
.rspec
@ -40,3 +41,6 @@
/index/*
rerun.txt
pickle-email-*.html
# Direnv
.envrc

View file

@ -62,7 +62,7 @@ group :test do
gem 'database_cleaner', '~> 1.2.0'
gem 'rspec-rails', '~> 2.14.1'
gem 'capybara', '~> 2.2.1'
gem 'poltergeist', '~> 1.5.0'
gem 'poltergeist', '~> 1.6.0'
gem 'selenium-webdriver', '~> 2.41.0'
gem 'factory_girl_rails', '~> 4.4.1'
gem 'timecop', '~> 0.7.1'

View file

@ -149,7 +149,7 @@ GEM
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
oj (2.5.5)
poltergeist (1.5.0)
poltergeist (1.6.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
multi_json (~> 1.0)
@ -249,7 +249,9 @@ GEM
execjs (>= 0.3.0)
json (>= 1.8.0)
websocket (1.0.7)
websocket-driver (0.3.3)
websocket-driver (0.5.4)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
will_paginate (3.0.5)
xpath (2.0.0)
nokogiri (~> 1.3)
@ -290,7 +292,7 @@ DEPENDENCIES
newrelic_rpm (~> 3.7.2.195)
nokogiri (~> 1.6.1)
oj (~> 2.5.5)
poltergeist (~> 1.5.0)
poltergeist (~> 1.6.0)
pry-byebug (~> 1.3.2)
puma (~> 2.11.1)
quiet_assets (~> 1.0.2)

View file

@ -1,75 +1,4 @@
$(document).ready(function(){
//
//function showNews(source, cat, content){
// new Ajax.Updater(content, '/categories/' + cat, {
// method: 'get'
// });
// var thisChild = source.parentNode.firstChild;
// while (thisChild != source.parentNode.lastChild) {
// if (thisChild.nodeType == 1 && thisChild.getAttribute("class") != "unread") {
// thisChild.setAttribute("class", "");
// }
// thisChild = thisChild.nextSibling;
// }
// source.setAttribute("class", "active");
//}
//function goToTheEnd(){
// var ed = tinyMCE.activeEditor;
// // This gets the root node of the editor window
// var root = ed.dom.getRoot();
// // And this gets the last node inside of it, so the last <p>...</p> tag
// var lastnode = root.childNodes[root.childNodes.length - 1];
//
// if (tinymce.isGecko) {
// // But firefox places the selection outside of that tag, so we need to go one level deeper:
// lastnode = lastnode.childNodes[lastnode.childNodes.length - 1];
// }
// // Now, we select the node
// ed.selection.select(lastnode);
// // And collapse the selection to the end to put the caret there:
// ed.selection.collapse(false);
//}
//
//var myrules = {
// '.remove': function(e){
// el = Event.findElement(e);
// target = el.href.replace(/.*#/, '.')
// el.up(target).hide();
// if (hidden_input = el.previous("input[type=hidden]")) {
// hidden_input.value = '1'
// }
// }
//};
//
//Event.observe(window, 'load', function(){
// $('container').delegate('click', myrules);
//});
//
//function changeCssClass(id, newclass){
// var obj = document.getElementById(id)
// obj.setAttribute("class", newclass);
// obj.setAttribute("className", newclass);
// obj.className = newclass;
//};
//
//function changeTab(container, tab){
// $(tab).style.visibility = 'hidden';
//};
//
//function Trash(source){
// var input = document.createElement("input");
// input.name = "deleted[reason]";
// input.type = "hidden";
// input.value = prompt('Enter reason', 'Violation of rule #');
// if (input.value == null) {
// return
// }
// source.appendChild(input);
// source.submit();
//}
// User popup
var userInfoTimeout;
@ -95,14 +24,6 @@ $(document).ready(function(){
function HideUserPopupRunner(){
document.getElementById("userPopup").style.visibility = "Hidden";
}
// Shoutbox
$.PeriodicalUpdater("/shoutmsgs/index.js", {
method: "GET",
type: "script",
minTimeout: 10000,
multiplier: 2
});
});
$(function() {

View file

@ -8,4 +8,15 @@
<%= render partial: "shoutmsgs/new", locals: { shoutmsg: Shoutmsg.new } %>
<%= link_to "Shoutbox Recent History", controller: :shoutmsgs, action: "index" %><br/>
<%= link_to "Shoutbox Rules", article_path(Article::SB_RULES) %>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$.PeriodicalUpdater("/shoutmsgs/index.js", {
method: "GET",
type: "script",
minTimeout: 10000,
multiplier: 2
});
});
</script>

View file

@ -0,0 +1,26 @@
require 'spec_helper'
feature 'Shoutbox' do
background do
@user = create :user
sign_in_as @user
visit root_path
end
feature 'user creates a shout', js: true do
scenario 'shouting with valid content' do
shout = rand(100000).to_s
fill_in 'shoutbox_text', with: shout
click_button 'Shout!'
expect(page).to have_content(shout)
end
scenario 'unable to while banned' do
@user.bans.create! ban_type: Ban::TYPE_MUTE, expiry: Time.now + 10.days
shout = rand(100000).to_s
fill_in 'shoutbox_text', with: shout
click_button 'Shout!'
expect(page).to_not have_content(shout)
end
end
end