* Create DiscussionLocks
* Fix specs
* Update nullify_blank_notes_and_reason
* Update before_validation call
* Updated DiscussionLockPolicy for clarity
* Move permitted_attributes to a constant
* Update route
* Apply suggestions from code review for frontend
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
* Add title tags
* Wrap unlock confirm in main element
* Wrap flash messages up in div
* Actually fix title tags
* Hide comment reply button when discussion is locked
* Add E2E tests
* Try to fix E2E tests
* Cypress...you work locally but not in CI...why!?
* PR feedback
* Update E2E tests
* More E2E updates 😭
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
17 lines
458 B
Ruby
17 lines
458 B
Ruby
class DiscussionLock < ApplicationRecord
|
|
belongs_to :article
|
|
belongs_to :locking_user, class_name: "User"
|
|
|
|
before_validation :nullify_blank_notes_and_reason
|
|
|
|
validates :article_id, presence: true, uniqueness: true
|
|
validates :locking_user_id, presence: true
|
|
|
|
private
|
|
|
|
def nullify_blank_notes_and_reason
|
|
# Prevent blank strings from beings saved to the DB
|
|
self.notes = nil if notes.blank?
|
|
self.reason = nil if reason.blank?
|
|
end
|
|
end
|