add mailto

This commit is contained in:
Tanguy PATTE 2015-08-25 16:33:55 +02:00
parent 12760a43d7
commit 54b4679d19
8 changed files with 34 additions and 2 deletions

View file

@ -0,0 +1,3 @@
class Admin::CommentairesController < CommentairesController
before_action :authenticate_user!
end

View file

@ -32,10 +32,15 @@ class Dossier < ActiveRecord::Base
end end
end end
def mailto
"mailto:#{formulaire.email_contact}?subject=Demande%20de%20contact&body=Bonjour,%0A%0AJe%20vous%20informe%20que%20j'ai%20rempli%20le%20dossier%20sur%20admi_facile.%20Vous%20pouvez%20y%20acc%C3%A9der%20en%20suivant%20le%20lien%20suivant%20:%20%0Ahttps://admi_facile.apientreprise.fr/admin/dossiers/#{id}%20%0A%20Le%20num%C3%A9ro%20de%20mon%20dossier%20est%20le%20#{id}"
end
private private
def build_default_cerfa def build_default_cerfa
build_cerfa build_cerfa
true true
end end
end end

View file

@ -14,7 +14,7 @@
%br %br
%h4{style: 'margin-bottom:2%'} Nouveau %h4{style: 'margin-bottom:2%'} Nouveau
= form_tag(url_for({controller: '/commentaires', action: :create}), class: 'form-inline', method: 'POST') do = form_tag(url_for({ controller: :commentaires, action: :create, dossier_id: @dossier.id }), class: 'form-inline', method: 'POST') do
%input.form-control{:type => 'text', style: 'width: 30%; margin-bottom:2%', :id => 'email_commentaire', :name => 'email_commentaire', :value => @commentaire_email} %input.form-control{:type => 'text', style: 'width: 30%; margin-bottom:2%', :id => 'email_commentaire', :name => 'email_commentaire', :value => @commentaire_email}
%textarea.form-control{:id => 'texte_commentaire', :name => 'texte_commentaire', style: 'width: 100%; margin-bottom:2%', rows: '5', maxlength: '255'} %textarea.form-control{:id => 'texte_commentaire', :name => 'texte_commentaire', style: 'width: 100%; margin-bottom:2%', rows: '5', maxlength: '255'}
%br %br

View file

@ -20,4 +20,8 @@
= render partial: '/dossiers/infos_dossier' = render partial: '/dossiers/infos_dossier'
%br %br
%a.btn.btn-success{ href: @dossier.mailto }
Contacter l'administration
= render partial: 'commentaires_flux' = render partial: 'commentaires_flux'

View file

@ -44,6 +44,7 @@ Rails.application.routes.draw do
namespace :admin do namespace :admin do
get '/dossiers/:dossier_id' => 'dossier#show' get '/dossiers/:dossier_id' => 'dossier#show'
get '/dossiers' => 'dossier#index' get '/dossiers' => 'dossier#index'
post '/commentaire' => 'commentaires#create'
end end
# The priority is based upon order of creation: first created -> highest priority. # The priority is based upon order of creation: first created -> highest priority.

View file

@ -29,7 +29,7 @@ feature '_Commentaires_Flux Admin/Dossier#Show Page' do
context 'Affichage du formulaire de commentaire' do context 'Affichage du formulaire de commentaire' do
scenario 'Le formulaire envoie vers /dossiers/:dossier_id/commentaire en #POST' do scenario 'Le formulaire envoie vers /dossiers/:dossier_id/commentaire en #POST' do
expect(page).to have_selector("form[action='/dossiers/#{dossier_id}/commentaire'][method=post]") expect(page).to have_selector("form[action='/admin/commentaire?dossier_id=#{dossier_id}'][method=post]")
end end
scenario 'Champs de texte' do scenario 'Champs de texte' do

View file

@ -121,5 +121,12 @@ describe Dossier do
end end
end end
end end
describe '#mailto' do
let(:dossier) { create(:dossier) }
let(:email_contact) { dossier.formulaire.email_contact }
subject { dossier.mailto }
it { is_expected.to eq("mailto:#{email_contact}?subject=Demande%20de%20contact&body=Bonjour,%0A%0AJe%20vous%20informe%20que%20j'ai%20rempli%20le%20dossier%20sur%20admi_facile.%20Vous%20pouvez%20y%20acc%C3%A9der%20en%20suivant%20le%20lien%20suivant%20:%20%0Ahttps://admi_facile.apientreprise.fr/admin/dossiers/#{dossier.id}%20%0A%20Le%20num%C3%A9ro%20de%20mon%20dossier%20est%20le%20#{dossier.id}")}
end
end end
end end

View file

@ -0,0 +1,12 @@
require 'spec_helper'
describe 'recapitulatif/show.html.haml', type: :view do
let(:dossier) { create(:dossier, :with_entreprise) }
before do
assign(:dossier, dossier.decorate)
assign(:commentaires, dossier.commentaires)
render
end
it { expect(rendered).to have_content("Contacter l'administration") }
it { expect(rendered).to include(dossier.mailto.gsub('&','&amp;')) }
end