mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: optionally allow tags in topic tracking state
This feature allows certain plugins to output tag information to topic tracking state, this allows per tag stats which can be used by sidebars and other plugins that need per tag stats Not enabled by default cause this would add cost to a critical query
This commit is contained in:
@@ -548,6 +548,41 @@ describe TopicTrackingState do
|
||||
|
||||
end
|
||||
|
||||
context "tag support" do
|
||||
after do
|
||||
# this is a bit of an odd hook, but this is a global change
|
||||
# used by plugins that leverage tagging heavily and need
|
||||
# tag information in topic tracking state
|
||||
TopicTrackingState.include_tags_in_report = false
|
||||
end
|
||||
|
||||
it "correctly handles tags" do
|
||||
SiteSetting.tagging_enabled = true
|
||||
|
||||
post.topic.notifier.watch_topic!(post.topic.user_id)
|
||||
|
||||
DiscourseTagging.tag_topic_by_names(
|
||||
post.topic,
|
||||
Guardian.new(Discourse.system_user),
|
||||
['bananas', 'apples']
|
||||
)
|
||||
|
||||
TopicTrackingState.include_tags_in_report = true
|
||||
|
||||
report = TopicTrackingState.report(user)
|
||||
expect(report.length).to eq(1)
|
||||
row = report[0]
|
||||
expect(row.tags).to contain_exactly("apples", "bananas")
|
||||
|
||||
TopicTrackingState.include_tags_in_report = false
|
||||
|
||||
report = TopicTrackingState.report(user)
|
||||
expect(report.length).to eq(1)
|
||||
row = report[0]
|
||||
expect(row.respond_to? :tags).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
it "correctly gets the tracking state" do
|
||||
report = TopicTrackingState.report(user)
|
||||
expect(report.length).to eq(0)
|
||||
|
||||
Reference in New Issue
Block a user