From 377720519180d8452144e1c6cae3a0217fa5e524 Mon Sep 17 00:00:00 2001 From: Reid Beels Date: Fri, 4 Oct 2013 00:14:21 -0700 Subject: [PATCH] Tighten up too_many_links? regexp Per discussion in #41, we don't want to stop people from legitimately discussing HTTP-related topics at user groups. Fixes #41 --- app/controllers/events_controller.rb | 2 +- spec/controllers/events_controller_spec.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 1768d89d..cde18d76 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -230,7 +230,7 @@ def clone # Checks if the description has too many links # which is probably spam def too_many_links?(description) - description.present? && description.scan(/http/i).size > 3 + description.present? && description.scan(/https?:\/\//i).size > 3 end # Export +events+ to an iCalendar file. diff --git a/spec/controllers/events_controller_spec.rb b/spec/controllers/events_controller_spec.rb index 1a7bccc0..20b5489c 100644 --- a/spec/controllers/events_controller_spec.rb +++ b/spec/controllers/events_controller_spec.rb @@ -431,6 +431,21 @@ flash[:failure].should match /too many links/i end + it "should accept HTTP-rich presentation descriptions without too many links" do + @params[:event][:description] = <<-DESC + I hereby offer to give a presentation at the August ruby meeting about the faraday + gem (https://github.com/lostisland/faraday) and how compares to or compliments other + HTTP client libraries such as httparty (https://github.com/jnunemaker/httparty). + + -- + + I wouldn't mind seeing a PDX.pm talk about HTTP::Tiny vs Net::HTTP::Tiny vs Net::HTTP + vs HTTP::Client vs HTTP::Client::Parallel + DESC + post "create", @params + flash[:failure].should be_nil + end + it "should allow the user to preview the event" do event = Event.new(:title => "Awesomeness") Event.should_receive(:new).and_return(event)