* Rubocop enabled style/alias * Enabled Style/ArrayJoin Cop * Enabled Style/Attr * Enabled Case Equality * Enabled CharacterLiteral * Enabled ColonMethodCall Cop * Enabled CommentAnnotation cop * Enabled PreferredHashMethods Cop * Enabled DoubleNegation Cop * Enabled EachWithObject Cop * Enabled EmptyLiteral Cop * Enabled EvenOdd Cop * Enabled IfWithSemicolon Cop * Enabled Lambda and LambdaCall Cop * Enabled LineEndConcatenation Cop * Enabled ModuleFunction Cop; * Enable NegatedIf and NegatedWhile Cop * Enabled NilComparison Cop * Enabled Not Cop * Enabled NumericLiterals Cop * Enabled OneLineConditional Cop * Enabled PercentLiteralDelimiters Cop * Excluded internal/users_controller from negated_if cop * Reverted the double negation change from github_issue_tag and github_issue.rb" * Enabled PerlBackrefs Cop * Changed Regexp.last_match(1) to Regexp.last_match(0) * Enabled proc cop * Enabled RaiseArgs Cop * Reverted Regexp.last_match(0) to Regexp.last_match(1) * Enabled SelfAssignment Cop * Enabled SingleLineMethods Cop * Enabled SpecialGlobalVars Cop * Enabled VariableInterpolation Cop * Enabled WhenThen Cop * Enabled WhileUntilModifier Cop * Enabled WordArray Cop * Enabled IfUnlessModifier Cop * Enabled GuardClause Cop
26 lines
960 B
Ruby
26 lines
960 B
Ruby
class FeedbackMessage < ApplicationRecord
|
|
belongs_to :offender, foreign_key: "offender_id", class_name: "User", optional: true
|
|
belongs_to :reviewer, foreign_key: "reviewer_id", class_name: "User", optional: true
|
|
belongs_to :reporter, foreign_key: "reporter_id", class_name: "User", optional: true
|
|
belongs_to :affected, foreign_key: "affected_id", class_name: "User", optional: true
|
|
has_many :notes, as: :noteable, dependent: :destroy
|
|
|
|
validates_presence_of :feedback_type, :message
|
|
validates_presence_of :reported_url, :category, if: :abuse_report?
|
|
validates :category,
|
|
inclusion: {
|
|
in: ["spam", "other", "rude or vulgar", "harassment", "bug"]
|
|
}
|
|
validates :status,
|
|
inclusion: {
|
|
in: %w[Open Invalid Resolved]
|
|
}
|
|
|
|
def abuse_report?
|
|
feedback_type == "abuse-reports"
|
|
end
|
|
|
|
def capitalize_status
|
|
self.status = status.capitalize unless status.blank?
|
|
end
|
|
end
|