Fix NoMethodError bug when params[:_rucaptha] is nil.
This commit is contained in:
parent
be7d72feb0
commit
e5ff2b9e77
|
@ -1,3 +1,8 @@
|
|||
0.4.2
|
||||
-----
|
||||
|
||||
- Fix NoMethodError bug when params[:_rucaptha] is nil.
|
||||
|
||||
0.4.1
|
||||
-----
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
rucaptcha (0.4.1)
|
||||
rucaptcha (0.4.2)
|
||||
posix-spawn (>= 0.3.0)
|
||||
|
||||
GEM
|
||||
|
|
|
@ -15,7 +15,7 @@ module RuCaptcha
|
|||
|
||||
def verify_rucaptcha?(resource = nil)
|
||||
rucaptcha_at = session[:_rucaptcha_at].to_i
|
||||
captcha = params[:_rucaptcha].downcase.strip
|
||||
captcha = (params[:_rucaptcha] || '').downcase.strip
|
||||
|
||||
# Captcha chars in Session expire in 2 minutes
|
||||
valid = false
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module RuCaptcha
|
||||
VERSION = '0.4.1'
|
||||
VERSION = '0.4.2'
|
||||
end
|
||||
|
|
|
@ -22,6 +22,19 @@ describe RuCaptcha do
|
|||
end
|
||||
|
||||
describe '.verify_rucaptcha?' do
|
||||
context 'Nil of param' do
|
||||
it 'should work when params[:_rucaptcha] is nil' do
|
||||
simple.params[:_rucaptcha] = nil
|
||||
expect(simple.verify_rucaptcha?).to eq(false)
|
||||
end
|
||||
|
||||
it 'should work when session[:_rucaptcha] is nil' do
|
||||
simple.session[:_rucaptcha] = nil
|
||||
simple.params[:_rucaptcha] = 'Abcd'
|
||||
expect(simple.verify_rucaptcha?).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context 'Correct chars in params' do
|
||||
it 'should work' do
|
||||
simple.session[:_rucaptcha_at] = Time.now.to_i
|
||||
|
|
Loading…
Reference in New Issue