Skip to content

Commit

Permalink
Test success with invisible_captcha
Browse files Browse the repository at this point in the history
  • Loading branch information
dacook committed Jan 25, 2024
1 parent 0638b9e commit 2535435
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions spec/system/consumer/authentication_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,6 @@
expect(page).to have_content "doesn't match"
end

it "Failing to sign up because the user is too quick" do
InvisibleCaptcha.timestamp_enabled = true
InvisibleCaptcha.timestamp_threshold = 30

fill_in "Your email", with: "[email protected]"
fill_in "Choose a password", with: "test12345"
fill_in "Confirm password", with: "test12345"
click_signup_button

expect(page).to have_content "Sorry, that was too quick! Please resubmit."

InvisibleCaptcha.timestamp_enabled = false
InvisibleCaptcha.timestamp_threshold = 30
end

it "Signing up successfully" do
fill_in "Your email", with: "[email protected]"
fill_in "Choose a password", with: "test12345"
Expand All @@ -135,6 +120,35 @@
'your account.'
end.to enqueue_job ActionMailer::MailDeliveryJob
end

describe "invisible_captcha gem" do
around do |example|
InvisibleCaptcha.timestamp_enabled = true
InvisibleCaptcha.timestamp_threshold = 30
example.run
InvisibleCaptcha.timestamp_enabled = false
end

it "Failing to sign up because the user is too quick" do
fill_in "Your email", with: "[email protected]"
fill_in "Choose a password", with: "test12345"
fill_in "Confirm password", with: "test12345"
click_signup_button

expect(page).to have_content "Sorry, that was too quick! Please resubmit."
end

it "succeeding after time threshold" do
Timecop.travel(30.seconds.from_now) do
fill_in "Your email", with: "[email protected]"
fill_in "Choose a password", with: "test12345"
fill_in "Confirm password", with: "test12345"
click_signup_button

expect(page).to have_content 'A message with a confirmation link has been sent'
end
end
end
end

describe "forgetting passwords" do
Expand Down

0 comments on commit 2535435

Please sign in to comment.