From 5d6d21f690e283682b9be74a8f00c501b148856f Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Wed, 26 Mar 2014 17:00:20 +0000 Subject: Add honeypot spam protection to contact form Intercepts the request and redirects to the homepage if the comment field is filled in on the contact form. --- spec/controllers/help_controller_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'spec/controllers/help_controller_spec.rb') diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb index 8ac10e244..f92323f50 100644 --- a/spec/controllers/help_controller_spec.rb +++ b/spec/controllers/help_controller_spec.rb @@ -58,6 +58,23 @@ describe HelpController do deliveries.clear end + it 'has rudimentary spam protection' do + post :contact, { :contact => { + :name => 'Vinny Vanilli', + :email => 'vinny@localhost', + :subject => 'Why do I have such an ace name?', + :comment => 'I AM A SPAMBOT', + :message => "You really should know!!!\n\nVinny", + }, :submitted_contact_form => 1 + } + + response.should redirect_to(frontpage_path) + + deliveries = ActionMailer::Base.deliveries + deliveries.size.should == 0 + deliveries.clear + end + end end -- cgit v1.2.3