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:
@@ -1,4 +1,4 @@
|
||||
class AnomalyNotification < ActiveRecord::Base
|
||||
class AnomalyNotification < ApplicationRecord
|
||||
belongs_to :user, polymorphic: true
|
||||
belongs_to :exercise
|
||||
belongs_to :exercise_collection
|
||||
|
3
app/models/application_record.rb
Normal file
3
app/models/application_record.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
end
|
@@ -1,4 +1,4 @@
|
||||
class CodeHarborLink < ActiveRecord::Base
|
||||
class CodeHarborLink < ApplicationRecord
|
||||
validates :oauth2token, presence: true
|
||||
validates :user_id, presence: true
|
||||
|
||||
|
@@ -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]
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class Comment < ActiveRecord::Base
|
||||
class Comment < ApplicationRecord
|
||||
# inherit the creation module: encapsulates that this is a polymorphic user, offers some aliases and makes sure that all necessary attributes are set.
|
||||
include Creation
|
||||
attr_accessor :username, :date, :updated, :editable
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class Consumer < ActiveRecord::Base
|
||||
class Consumer < ApplicationRecord
|
||||
has_many :users
|
||||
|
||||
scope :with_users, -> { where('id IN (SELECT consumer_id FROM internal_users)') }
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class Error < ActiveRecord::Base
|
||||
class Error < ApplicationRecord
|
||||
belongs_to :execution_environment
|
||||
|
||||
scope :for_execution_environment, ->(execution_environment) { where(execution_environment_id: execution_environment.id) }
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class ErrorTemplate < ActiveRecord::Base
|
||||
class ErrorTemplate < ApplicationRecord
|
||||
belongs_to :execution_environment
|
||||
has_and_belongs_to_many :error_template_attributes
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class ErrorTemplateAttribute < ActiveRecord::Base
|
||||
class ErrorTemplateAttribute < ApplicationRecord
|
||||
has_and_belongs_to_many :error_template
|
||||
|
||||
def to_s
|
||||
|
@@ -1,7 +1,7 @@
|
||||
class Event < ActiveRecord::Base
|
||||
class Event < ApplicationRecord
|
||||
belongs_to :user, polymorphic: true
|
||||
belongs_to :exercise
|
||||
belongs_to :file
|
||||
belongs_to :file, class_name: 'CodeOcean::File'
|
||||
|
||||
validates :category, presence: true
|
||||
validates :data, presence: true
|
||||
|
@@ -1,6 +1,6 @@
|
||||
require File.expand_path('../../../lib/active_model/validations/boolean_presence_validator', __FILE__)
|
||||
|
||||
class ExecutionEnvironment < ActiveRecord::Base
|
||||
class ExecutionEnvironment < ApplicationRecord
|
||||
include Creation
|
||||
include DefaultValues
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
require 'nokogiri'
|
||||
require File.expand_path('../../../lib/active_model/validations/boolean_presence_validator', __FILE__)
|
||||
|
||||
class Exercise < ActiveRecord::Base
|
||||
class Exercise < ApplicationRecord
|
||||
include Context
|
||||
include Creation
|
||||
include DefaultValues
|
||||
@@ -23,8 +23,8 @@ class Exercise < ActiveRecord::Base
|
||||
accepts_nested_attributes_for :exercise_tags
|
||||
has_many :user_exercise_feedbacks
|
||||
|
||||
has_many :external_users, source: :user, source_type: ExternalUser, through: :submissions
|
||||
has_many :internal_users, source: :user, source_type: InternalUser, through: :submissions
|
||||
has_many :external_users, source: :user, source_type: 'ExternalUser', through: :submissions
|
||||
has_many :internal_users, source: :user, source_type: 'InternalUser', through: :submissions
|
||||
alias_method :users, :external_users
|
||||
|
||||
scope :with_submissions, -> { where('id IN (SELECT exercise_id FROM submissions)') }
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class ExerciseCollection < ActiveRecord::Base
|
||||
class ExerciseCollection < ApplicationRecord
|
||||
include TimeHelper
|
||||
|
||||
has_many :exercise_collection_items, dependent: :delete_all
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class ExerciseCollectionItem < ActiveRecord::Base
|
||||
class ExerciseCollectionItem < ApplicationRecord
|
||||
belongs_to :exercise_collection
|
||||
belongs_to :exercise
|
||||
end
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class ExerciseTag < ActiveRecord::Base
|
||||
class ExerciseTag < ApplicationRecord
|
||||
|
||||
belongs_to :tag
|
||||
belongs_to :exercise
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class ExternalUser < ActiveRecord::Base
|
||||
class ExternalUser < ApplicationRecord
|
||||
include User
|
||||
|
||||
validates :consumer_id, presence: true
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class FileTemplate < ActiveRecord::Base
|
||||
class FileTemplate < ApplicationRecord
|
||||
|
||||
belongs_to :file_type
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
require File.expand_path('../../../lib/active_model/validations/boolean_presence_validator', __FILE__)
|
||||
|
||||
class FileType < ActiveRecord::Base
|
||||
class FileType < ApplicationRecord
|
||||
include Creation
|
||||
include DefaultValues
|
||||
|
||||
@@ -11,7 +11,7 @@ class FileType < ActiveRecord::Base
|
||||
after_initialize :set_default_values
|
||||
|
||||
has_many :execution_environments
|
||||
has_many :files
|
||||
has_many :files, class_name: 'CodeOcean::File'
|
||||
has_many :file_templates
|
||||
|
||||
validates :binary, boolean_presence: true
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class Hint < ActiveRecord::Base
|
||||
class Hint < ApplicationRecord
|
||||
belongs_to :execution_environment
|
||||
|
||||
validates :execution_environment_id, presence: true
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class InternalUser < ActiveRecord::Base
|
||||
class InternalUser < ApplicationRecord
|
||||
include User
|
||||
|
||||
authenticates_with_sorcery!
|
||||
|
@@ -1,7 +1,7 @@
|
||||
class Intervention < ActiveRecord::Base
|
||||
class Intervention < ApplicationRecord
|
||||
|
||||
has_many :user_exercise_interventions
|
||||
has_many :users, through: :user_exercise_interventions, source_type: "ExternalUser"
|
||||
has_many :users, through: :user_exercise_interventions, source_type: 'ExternalUser'
|
||||
|
||||
def to_s
|
||||
name
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class LtiParameter < ActiveRecord::Base
|
||||
class LtiParameter < ApplicationRecord
|
||||
belongs_to :consumer, foreign_key: "consumers_id"
|
||||
belongs_to :exercise, foreign_key: "exercises_id"
|
||||
belongs_to :external_user, foreign_key: "external_users_id"
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class ProxyExercise < ActiveRecord::Base
|
||||
class ProxyExercise < ApplicationRecord
|
||||
|
||||
after_initialize :generate_token
|
||||
after_initialize :set_reason
|
||||
|
@@ -1,5 +1,5 @@
|
||||
# todo: reference to lti_param_model
|
||||
class RemoteEvaluationMapping < ActiveRecord::Base
|
||||
class RemoteEvaluationMapping < ApplicationRecord
|
||||
before_create :generate_token, unless: :validation_token?
|
||||
belongs_to :exercise
|
||||
belongs_to :user
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class RequestForComment < ActiveRecord::Base
|
||||
class RequestForComment < ApplicationRecord
|
||||
include Creation
|
||||
belongs_to :submission
|
||||
belongs_to :exercise
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class Search < ActiveRecord::Base
|
||||
class Search < ApplicationRecord
|
||||
belongs_to :user, polymorphic: true
|
||||
belongs_to :exercise
|
||||
end
|
@@ -1,7 +1,6 @@
|
||||
class StructuredError < ActiveRecord::Base
|
||||
class StructuredError < ApplicationRecord
|
||||
belongs_to :error_template
|
||||
belongs_to :submission
|
||||
belongs_to :file, class_name: 'CodeOcean::File'
|
||||
|
||||
has_many :structured_error_attributes
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class StructuredErrorAttribute < ActiveRecord::Base
|
||||
class StructuredErrorAttribute < ApplicationRecord
|
||||
belongs_to :structured_error
|
||||
belongs_to :error_template_attribute
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class Submission < ActiveRecord::Base
|
||||
class Submission < ApplicationRecord
|
||||
include Context
|
||||
include Creation
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class Subscription < ActiveRecord::Base
|
||||
class Subscription < ApplicationRecord
|
||||
belongs_to :user, polymorphic: true
|
||||
belongs_to :request_for_comment
|
||||
end
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class Tag < ActiveRecord::Base
|
||||
class Tag < ApplicationRecord
|
||||
|
||||
has_many :exercise_tags
|
||||
has_many :exercises, through: :exercise_tags
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class Testrun < ActiveRecord::Base
|
||||
class Testrun < ApplicationRecord
|
||||
belongs_to :file, class_name: 'CodeOcean::File'
|
||||
belongs_to :submission
|
||||
end
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class UserExerciseFeedback < ActiveRecord::Base
|
||||
class UserExerciseFeedback < ApplicationRecord
|
||||
include Creation
|
||||
|
||||
belongs_to :exercise
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class UserExerciseIntervention < ActiveRecord::Base
|
||||
class UserExerciseIntervention < ApplicationRecord
|
||||
|
||||
belongs_to :user, polymorphic: true
|
||||
belongs_to :intervention
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class UserProxyExerciseExercise < ActiveRecord::Base
|
||||
class UserProxyExerciseExercise < ApplicationRecord
|
||||
|
||||
belongs_to :user, polymorphic: true
|
||||
belongs_to :exercise
|
||||
|
Reference in New Issue
Block a user