mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
Add default timeout value & task test
This commit is contained in:
parent
16db7358cd
commit
517b4b2fe2
2 changed files with 4 additions and 3 deletions
|
@ -4,7 +4,7 @@ class EppSession < ApplicationRecord
|
|||
validates :session_id, uniqueness: true, presence: true
|
||||
|
||||
class_attribute :timeout
|
||||
self.timeout = ENV['epp_session_timeout_seconds'].to_i.seconds
|
||||
self.timeout = (ENV['epp_session_timeout_seconds'] || 300).to_i.seconds
|
||||
|
||||
alias_attribute :last_access, :updated_at
|
||||
|
||||
|
|
|
@ -10,14 +10,15 @@ class EppClearExpiredSessionsTaskTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_clears_expired_epp_sessions
|
||||
timeout = 0.second
|
||||
EppSession.timeout = timeout
|
||||
timeout = EppSession.timeout
|
||||
session = epp_sessions(:api_bestnames)
|
||||
next_session = epp_sessions(:api_goodnames)
|
||||
session.update!(updated_at: Time.zone.now - timeout - 1.second)
|
||||
|
||||
run_task
|
||||
|
||||
assert_nil EppSession.find_by(session_id: session.session_id)
|
||||
assert EppSession.find_by(session_id: next_session.session_id)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue