Skip to content

Commit

Permalink
Tighten up too_many_links? regexp
Browse files Browse the repository at this point in the history
Per discussion in #41, we don't want to stop people from legitimately
discussing HTTP-related topics at user groups.

Fixes #41
  • Loading branch information
reidab committed Oct 4, 2013
1 parent b63cc7c commit 3777205
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions spec/controllers/events_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3777205

Please sign in to comment.