diff --git a/.gitignore b/.gitignore index d4d3e2e..e76151e 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/Gemfile b/Gemfile index f22590d..b161b85 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index 70af6dc..a090d97 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/app/assets/javascripts/local.js b/app/assets/javascripts/local.js index 40ba551..d21797c 100644 --- a/app/assets/javascripts/local.js +++ b/app/assets/javascripts/local.js @@ -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

...

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() { diff --git a/app/views/widgets/_shoutbox.html.erb b/app/views/widgets/_shoutbox.html.erb index 606b88e..0bf5238 100644 --- a/app/views/widgets/_shoutbox.html.erb +++ b/app/views/widgets/_shoutbox.html.erb @@ -8,4 +8,15 @@ <%= render partial: "shoutmsgs/new", locals: { shoutmsg: Shoutmsg.new } %> <%= link_to "Shoutbox Recent History", controller: :shoutmsgs, action: "index" %>
<%= link_to "Shoutbox Rules", article_path(Article::SB_RULES) %> - \ No newline at end of file + + + \ No newline at end of file diff --git a/spec/features/shoutbox/shoutbox_spec.rb b/spec/features/shoutbox/shoutbox_spec.rb new file mode 100644 index 0000000..30d75ac --- /dev/null +++ b/spec/features/shoutbox/shoutbox_spec.rb @@ -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 \ No newline at end of file