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



75
76
77
78
79
80
81
# File 'lib/inferno/repositories/test_sessions.rb', line 75

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



83
84
85
86
87
88
89
# File 'lib/inferno/repositories/test_sessions.rb', line 83

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