docbrown/app/models/feedback_message.rb
Anna Buianova 01456fe029 [deploy] Finalize deleting user associations (#5624)
* Prepare factories and associations for Users::DeleteActivity specs

* Altered user associations, delete the needed associations in Users::DeleteActivity

* Moved and refined user deletion spec

* Removed useless commented user associations

* Refactored BackupData factory

* Refactored ProfilePin factory

* Refactored Reaction factory

* Fixed specs: Keep default _type in factories or specify it in tests

* Ok, notes shouldn't be deleted on user deletion

* Fixed creating reactable for specs

* Specify commentable/commentable_type explicitly when creating data for tests

* Fixed typo in the comments spec

* Removed unnneeded space

* Added aggregate_failures for testing user associations deletion

* Keep feedback_messages while deleting user activities
2020-01-23 11:29:47 -05:00

25 lines
1 KiB
Ruby

class FeedbackMessage < ApplicationRecord
belongs_to :offender, foreign_key: "offender_id", class_name: "User", optional: true, inverse_of: :offender_feedback_messages
belongs_to :reporter, foreign_key: "reporter_id", class_name: "User", optional: true, inverse_of: :reporter_feedback_messages
belongs_to :affected, foreign_key: "affected_id", class_name: "User", optional: true, inverse_of: :affected_feedback_messages
has_many :notes, as: :noteable, inverse_of: :noteable, dependent: :destroy
validates :feedback_type, :message, presence: true
validates :reported_url, :category, presence: { if: :abuse_report? }
validates :category,
inclusion: {
in: ["spam", "other", "rude or vulgar", "harassment", "bug", "listings"]
}
validates :status,
inclusion: {
in: %w[Open Invalid Resolved]
}
def abuse_report?
feedback_type == "abuse-reports"
end
def capitalize_status
self.status = status.capitalize if status.present?
end
end