Fix test case
This commit is contained in:
parent
d0d6718e15
commit
58ab0adb75
|
@ -1,6 +1,8 @@
|
|||
language: ruby
|
||||
rvm:
|
||||
- 2.2.3
|
||||
services:
|
||||
- memcached
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
|
|
|
@ -46,6 +46,7 @@ GEM
|
|||
builder (3.2.2)
|
||||
concurrent-ruby (1.0.2)
|
||||
concurrent-ruby (1.0.2-java)
|
||||
dalli (2.7.6)
|
||||
diff-lcs (1.2.5)
|
||||
erubis (2.7.0)
|
||||
globalid (0.3.6)
|
||||
|
@ -125,6 +126,7 @@ PLATFORMS
|
|||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
dalli
|
||||
mini_magick
|
||||
rails
|
||||
rake
|
||||
|
|
|
@ -20,7 +20,11 @@ module RuCaptcha
|
|||
@config.cache_limit = 100
|
||||
@config.expires_in = 2.minutes
|
||||
@config.style = :colorful
|
||||
@config.cache_store = Rails.application.config.cache_store
|
||||
if Rails.application
|
||||
@config.cache_store = Rails.application.config.cache_store
|
||||
else
|
||||
@config.cache_store = :null_store
|
||||
end
|
||||
@config
|
||||
end
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ module RuCaptcha
|
|||
end
|
||||
|
||||
# Make sure not expire
|
||||
puts "-------------- #{store_info.inspect}"
|
||||
if (Time.now.to_i - store_info[:time]) > RuCaptcha.config.expires_in
|
||||
return add_rucaptcha_validation_error
|
||||
end
|
||||
|
|
|
@ -19,11 +19,11 @@ describe RuCaptcha do
|
|||
end
|
||||
|
||||
def custom_session
|
||||
Rails.cache.read(self.rucaptcha_sesion_key_key)
|
||||
RuCaptcha.cache.read(self.rucaptcha_sesion_key_key)
|
||||
end
|
||||
|
||||
def clean_custom_session
|
||||
Rails.cache.delete(self.rucaptcha_sesion_key_key)
|
||||
RuCaptcha.cache.delete(self.rucaptcha_sesion_key_key)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -59,7 +59,7 @@ describe RuCaptcha do
|
|||
|
||||
context 'Correct chars in params' do
|
||||
it 'should work' do
|
||||
Rails.cache.write(simple.rucaptcha_sesion_key_key, {
|
||||
RuCaptcha.cache.write(simple.rucaptcha_sesion_key_key, {
|
||||
time: Time.now.to_i,
|
||||
code: 'abcd'
|
||||
})
|
||||
|
@ -67,7 +67,7 @@ describe RuCaptcha do
|
|||
expect(simple.verify_rucaptcha?).to eq(true)
|
||||
expect(simple.custom_session).to eq nil
|
||||
|
||||
Rails.cache.write(simple.rucaptcha_sesion_key_key, {
|
||||
RuCaptcha.cache.write(simple.rucaptcha_sesion_key_key, {
|
||||
time: Time.now.to_i,
|
||||
code: 'abcd'
|
||||
})
|
||||
|
@ -78,7 +78,7 @@ describe RuCaptcha do
|
|||
|
||||
describe 'Incorrect chars' do
|
||||
it 'should work' do
|
||||
Rails.cache.write(simple.rucaptcha_sesion_key_key, {
|
||||
RuCaptcha.cache.write(simple.rucaptcha_sesion_key_key, {
|
||||
time: Time.now.to_i - 60,
|
||||
code: 'abcd'
|
||||
})
|
||||
|
@ -90,7 +90,7 @@ describe RuCaptcha do
|
|||
|
||||
describe 'Expires Session key' do
|
||||
it 'should work' do
|
||||
Rails.cache.write(simple.rucaptcha_sesion_key_key, {
|
||||
RuCaptcha.cache.write(simple.rucaptcha_sesion_key_key, {
|
||||
time: Time.now.to_i - 121,
|
||||
code: 'abcd'
|
||||
})
|
||||
|
|
|
@ -24,4 +24,5 @@ RuCaptcha.configure do
|
|||
self.len = 2
|
||||
self.font_size = 48
|
||||
self.implode = 0.111
|
||||
self.cache_store = :mem_cache_store
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue