REFACTOR: Add basic tests for TopicTrackingState#publish_*.

* Ensure we don't publish events for PMs.
This commit is contained in:
Guo Xiang Tan
2018-03-05 16:18:23 +08:00
parent 821f3d0c15
commit d576056cff
3 changed files with 80 additions and 12 deletions

View File

@ -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)