mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 18:38:03 +08:00
REFACTOR: Add basic tests for TopicTrackingState#publish_*
.
* Ensure we don't publish events for PMs.
This commit is contained in:
@ -99,7 +99,7 @@ class Topic < ActiveRecord::Base
|
||||
if: Proc.new { |t|
|
||||
(t.new_record? || t.category_id_changed?) &&
|
||||
!SiteSetting.allow_uncategorized_topics &&
|
||||
(t.archetype.nil? || t.archetype == Archetype.default) &&
|
||||
(t.archetype.nil? || t.regular?) &&
|
||||
(!t.user_id || !t.user.staff?)
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ class Topic < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def ensure_topic_has_a_category
|
||||
if category_id.nil? && (archetype.nil? || archetype == Archetype.default)
|
||||
if category_id.nil? && (archetype.nil? || self.regular?)
|
||||
self.category_id = SiteSetting.uncategorized_category_id
|
||||
end
|
||||
end
|
||||
@ -463,6 +463,10 @@ class Topic < ActiveRecord::Base
|
||||
archetype == Archetype.private_message
|
||||
end
|
||||
|
||||
def regular?
|
||||
self.archetype == Archetype.default
|
||||
end
|
||||
|
||||
MAX_SIMILAR_BODY_LENGTH ||= 200
|
||||
|
||||
def self.similar_to(title, raw, user = nil)
|
||||
|
Reference in New Issue
Block a user