test(support): add contact-admin spec

This commit is contained in:
Colin Darie 2022-09-05 15:30:59 +02:00
parent a9aab27589
commit 7f1764fa66

View file

@ -149,4 +149,29 @@ describe SupportController, type: :controller do
end end
end end
end end
context 'contact admin' do
subject do
post :create, params: params
end
let(:params) { { admin: "true", email: "email@pro.fr", subject: 'bonjour', text: 'un message' } }
describe "when form is filled" do
it "creates a conversation on HelpScout" do
expect_any_instance_of(Helpscout::FormAdapter).to receive(:send_form).and_return(true)
subject
expect(flash[:notice]).to match('Votre message a été envoyé.')
end
end
describe "when invisible captcha is filled" do
let(:params) { super().merge(InvisibleCaptcha.honeypots.sample => 'boom') }
it 'does not create a conversation on HelpScout' do
subject
expect(flash[:alert]).to eq(I18n.t('invisible_captcha.sentence_for_humans'))
end
end
end
end end