blacklist some funding sources

This commit is contained in:
2016-06-04 14:39:16 +02:00
parent cb77ce5921
commit 96982e47a7
3 changed files with 29 additions and 10 deletions
@@ -9,7 +9,7 @@ module Cmtool
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @contact_forms }
format.xml { render xml: @contact_forms }
end
end
@@ -20,7 +20,7 @@ module Cmtool
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @contact_form }
format.xml { render xml: @contact_form }
end
end
@@ -31,7 +31,7 @@ module Cmtool
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @contact_form }
format.xml { render xml: @contact_form }
end
end
@@ -47,11 +47,11 @@ module Cmtool
respond_to do |format|
if @contact_form.save
format.html { redirect_to([cmtool, @contact_form], :notice => I18n.t('cmtool.action.create.successful', :model => Cmtool::ContactForm.model_name.human)) }
format.xml { render :xml => @contact_form, :status => :created, :location => @contact_form }
format.html { redirect_to([cmtool, @contact_form], notice: I18n.t('cmtool.action.create.successful', model: Cmtool::ContactForm.model_name.human)) }
format.xml { render xml: @contact_form, status: :created, location: @contact_form }
else
format.html { render :action => "new" }
format.xml { render :xml => @contact_form.errors, :status => :unprocessable_entity }
format.html { render action: "new" }
format.xml { render xml: @contact_form.errors, status: :unprocessable_entity }
end
end
end
@@ -63,11 +63,11 @@ module Cmtool
respond_to do |format|
if @contact_form.update_attributes(contact_form_params)
format.html { redirect_to([cmtool, @contact_form], :notice => I18n.t('cmtool.action.update.successful', :model => Cmtool::ContactForm.model_name.human)) }
format.html { redirect_to([cmtool, @contact_form], notice: I18n.t('cmtool.action.update.successful', model: Cmtool::ContactForm.model_name.human)) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @contact_form.errors, :status => :unprocessable_entity }
format.html { render action: "edit" }
format.xml { render xml: @contact_form.errors, status: :unprocessable_entity }
end
end
end
+9
View File
@@ -7,5 +7,14 @@ module Cmtool
property :phone
property :body
validates :email, presence: true
validate :if_there_are_bad_intentions
private
def if_there_are_bad_intentions
has_bad_intentions = false
has_bad_intentions = true if "#{email}#{body}" =~ /funded\.com/i
errors.add(:base, :bad_intentions) if has_bad_intentions
end
end
end
+10
View File
@@ -0,0 +1,10 @@
require 'spec_helper'
describe Cmtool::ContactForm do
it "is invalid with Funded.com in email or body" do
build(:contact_form).should be_valid
build(:contact_form, email: "fundingteam+url.com@getbusinessfunded.com").should_not be_valid
build(:contact_form, body: "fundingteam+url.com@getbusinessFunded.com").should_not be_valid
end
end