Commit 7459e821 authored by Alexandre Friquet's avatar Alexandre Friquet
Browse files

Add honeypot to contact form: refs #108.

parent 8362e33f
......@@ -27,6 +27,7 @@
<%= simple_form_for @mail, url: contact_us_path, html: {class: (@contact_message.present? ? '' : 'alone')} do |f| %>
<%= f.input :last_name %>
<%= f.input :first_name %>
<%= f.input :nickname, as: :hidden %>
<%= f.input :email %>
<%= f.input :phone_number %>
<%= f.input :subject %>
......
......@@ -40,6 +40,15 @@ feature "ContactUS mails" do
end
context "with email contact in settings" do
def fill_in_contact_us_correctly
fill_in "Nom", with: "Dupont"
fill_in "Prénom", with: "Jean"
fill_in "Adresse email", with: "jean-dupont@nowhere.com"
fill_in "Numéro de téléphone", with: "0102030405"
fill_in "Objet", with: "Contact"
fill_in "Message", with: "Bonjour, j'aurais voulu..."
end
scenario "I can send a correct email to the webmaster" do
visit root_path
within "footer" do
......@@ -48,12 +57,7 @@ feature "ContactUS mails" do
expect(current_path).to eq(new_contact_us_path)
within "form" do
fill_in "Nom", with: "Dupont"
fill_in "Prénom", with: "Jean"
fill_in "Adresse email", with: "jean-dupont@nowhere.com"
fill_in "Numéro de téléphone", with: "0102030405"
fill_in "Objet", with: "Contact"
fill_in "Message", with: "Bonjour, j'aurais voulu..."
fill_in_contact_us_correctly
click_button "Envoyer"
end
......@@ -71,18 +75,25 @@ feature "ContactUS mails" do
expect(page).to have_selector("span.error", text: "doit être rempli(e)")
end
scenario "I can see errors when nickname provided" do
visit new_contact_us_path
within "form" do
fill_in_contact_us_correctly
find("#contact_us_mail_nickname", visible: false).set "bibi"
click_button "Envoyer"
end
expect(current_path).to eq(contact_us_path)
expect(page).to have_selector("span.error", text: "n'est pas valide")
end
scenario "I am informed if an error occured while sending off the email" do
#Given
allow(Mailer).to receive_message_chain(:contact_us, :deliver_now).and_raise("Error")
# When
visit new_contact_us_path
within "form" do
fill_in "Nom", with: "Dupont"
fill_in "Prénom", with: "Jean"
fill_in "Adresse email", with: "jean-dupont@nowhere.com"
fill_in "Numéro de téléphone", with: "0102030405"
fill_in "Objet", with: "Contact"
fill_in "Message", with: "Bonjour, j'aurais voulu..."
fill_in_contact_us_correctly
click_button "Envoyer"
end
# Then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment