Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions spec/controllers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
InvisibleCaptcha.spinner_enabled = false
end

after(:each) { travel_back }

context 'without invisible_captcha_timestamp in session' do
it 'fails like if it was submitted too fast' do
post :create, params: { topic: { title: 'foo' } }
Expand Down Expand Up @@ -87,7 +89,7 @@ def custom_timestamp_callback

context 'successful submissions' do
it 'passes if submission on or after timestamp_threshold' do
sleep InvisibleCaptcha.timestamp_threshold
travel InvisibleCaptcha.timestamp_threshold

post :create, params: {
topic: {
Expand All @@ -105,7 +107,7 @@ def custom_timestamp_callback
end

it 'allow to set a custom timestamp_threshold per action' do
sleep 2 # custom threshold
travel 2 # custom threshold

post :publish, params: { id: 1 }

Expand All @@ -126,7 +128,7 @@ def custom_timestamp_callback
session[:invisible_captcha_timestamp] = Time.zone.now.iso8601

# Wait for valid submission
sleep InvisibleCaptcha.timestamp_threshold
travel InvisibleCaptcha.timestamp_threshold
end

it 'fails with spam' do
Expand Down Expand Up @@ -237,7 +239,7 @@ def custom_timestamp_callback
session[:invisible_captcha_timestamp] = Time.zone.now.iso8601

# Wait for valid submission
sleep InvisibleCaptcha.timestamp_threshold
travel InvisibleCaptcha.timestamp_threshold
end

after(:each) { InvisibleCaptcha.honeypot_enabled = true }
Expand Down Expand Up @@ -265,7 +267,7 @@ def custom_timestamp_callback
session[:invisible_captcha_spinner] = spinner_value

# Wait for valid submission
sleep InvisibleCaptcha.timestamp_threshold
travel InvisibleCaptcha.timestamp_threshold
end

it 'fails with no spam, but mismatch of spinner' do
Expand Down
Loading