Files
fizzy/app/models/card/statuses.rb
T
Rosa Gutierrez cb01966439 Remove unused Card.published_or_drafted_by scope
As the tests for it could lead to confusion where it seems drafted cards
are not accessible to someone with access to the board and with the
direct drafted card URL.
2025-12-19 09:46:21 +01:00

27 lines
590 B
Ruby

module Card::Statuses
extend ActiveSupport::Concern
included do
enum :status, %w[ drafted published ].index_by(&:itself)
before_save :mark_if_just_published
after_create -> { track_event :published }, if: :published?
end
attr_accessor :was_just_published
alias_method :was_just_published?, :was_just_published
def publish
transaction do
self.created_at = Time.current
published!
track_event :published
end
end
private
def mark_if_just_published
self.was_just_published = true if published? && status_changed?
end
end