From 7f1764fa66ae41cf7d702c48e3a7c7a41ce901e3 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Mon, 5 Sep 2022 15:30:59 +0200 Subject: [PATCH] test(support): add contact-admin spec --- spec/controllers/support_controller_spec.rb | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/controllers/support_controller_spec.rb b/spec/controllers/support_controller_spec.rb index ee1fbf312..d7275991d 100644 --- a/spec/controllers/support_controller_spec.rb +++ b/spec/controllers/support_controller_spec.rb @@ -149,4 +149,29 @@ describe SupportController, type: :controller do 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