Class: Inferno::Repositories::TestSessions::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/inferno/repositories/test_sessions.rb

Instance Method Summary collapse

Instance Method Details

#before_createObject



79
80
81
82
83
84
85
# File 'lib/inferno/repositories/test_sessions.rb', line 79

def before_create
  self.id = Base62.encode(SecureRandom.random_number(2**64))
  time = Time.now
  self.created_at ||= time
  self.updated_at ||= time
  super
end

#validateObject



87
88
89
90
91
92
93
# File 'lib/inferno/repositories/test_sessions.rb', line 87

def validate
  super
  errors.add(:test_suite_id, 'cannot be empty') if test_suite_id.blank?
  unless test_suites_repo.exists? test_suite_id # rubocop:disable Style/GuardClause
    errors.add(:test_suite_id, "'#{test_suite_id}' is not valid")
  end
end