Upgrade Rails to version 5.2.1 and adopt code & specs where necessary

Signed-off-by: Sebastian Serth <Sebastian.Serth@student.hpi.de>
This commit is contained in:
Sebastian Serth
2018-09-13 12:21:53 +02:00
parent 108190c242
commit de52db89f0
128 changed files with 786 additions and 422 deletions

View File

@ -15,7 +15,7 @@ module CodeOcean
end
end
class File < ActiveRecord::Base
class File < ApplicationRecord
include DefaultValues
DEFAULT_WEIGHT = 1.0
@ -28,12 +28,11 @@ module CodeOcean
before_validation :set_ancestor_values, if: :incomplete_descendent?
belongs_to :context, polymorphic: true
belongs_to :execution_environment
belongs_to :file
belongs_to :file, class_name: 'CodeOcean::File', optional: true # This is only required for submissions and is validated below
alias_method :ancestor, :file
belongs_to :file_type
has_many :files
has_many :files, class_name: 'CodeOcean::File'
has_many :testruns
has_many :comments
alias_method :descendants, :files
@ -59,6 +58,7 @@ module CodeOcean
validates :role, inclusion: {in: ROLES}
validates :weight, if: :teacher_defined_test?, numericality: true, presence: true
validates :weight, absence: true, unless: :teacher_defined_test?
validates :file, presence: true if :context.is_a?(Submission)
validates_with FileNameValidator, fields: [:name, :path, :file_type_id]