add spec for invalid captcha (#1569)
This commit is contained in:
parent
5bacb4e8c1
commit
6ca4aec6c8
1 changed files with 14 additions and 2 deletions
|
|
@ -3,7 +3,7 @@ require "rails_helper"
|
|||
RSpec.describe "feedback_messages", type: :request do
|
||||
describe "POST /feedback_messages" do
|
||||
# rubocop:disable RSpec/AnyInstance
|
||||
before do
|
||||
def verify_captcha_and_slack_ping
|
||||
allow_any_instance_of(FeedbackMessagesController).
|
||||
to receive(:recaptcha_verified?).and_return(true)
|
||||
allow(SlackBot).to receive(:ping).and_return(true)
|
||||
|
|
@ -21,6 +21,7 @@ RSpec.describe "feedback_messages", type: :request do
|
|||
|
||||
context "with valid params" do
|
||||
before do
|
||||
verify_captcha_and_slack_ping
|
||||
post "/feedback_messages", params: valid_abuse_report_params
|
||||
end
|
||||
|
||||
|
|
@ -35,10 +36,18 @@ RSpec.describe "feedback_messages", type: :request do
|
|||
end
|
||||
end
|
||||
|
||||
context "with invalid recaptcha" do
|
||||
it "rerenders page" do
|
||||
post "/feedback_messages", params: valid_abuse_report_params
|
||||
expect(response.body).to include("Make sure the forms are filled")
|
||||
end
|
||||
end
|
||||
|
||||
context "when a logged in user submits a report" do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
before do
|
||||
verify_captcha_and_slack_ping
|
||||
login_as(user)
|
||||
post "/feedback_messages", params: valid_abuse_report_params
|
||||
end
|
||||
|
|
@ -53,7 +62,10 @@ RSpec.describe "feedback_messages", type: :request do
|
|||
end
|
||||
|
||||
context "when a signed out users submits a report" do
|
||||
before { post "/feedback_messages", params: valid_abuse_report_params }
|
||||
before do
|
||||
verify_captcha_and_slack_ping
|
||||
post "/feedback_messages", params: valid_abuse_report_params
|
||||
end
|
||||
|
||||
it "does not add any user as the reporter" do
|
||||
expect(FeedbackMessage.last.reporter_id).to eq(nil)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue