mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FEATURE: New way to dismiss new topics (#11927)
This is a try to simplify logic around dismiss new topics to have one solution to work in all places - dismiss all-new, dismiss new in a specific category or even in a specific tag.
This commit is contained in:

committed by
GitHub

parent
151193bb11
commit
f39e7fe81d
@ -2867,28 +2867,24 @@ RSpec.describe TopicsController do
|
||||
context 'category' do
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:subcategory) { Fabricate(:category, parent_category_id: category.id) }
|
||||
fab!(:category_topic) { Fabricate(:topic, category: category) }
|
||||
fab!(:subcategory_topic) { Fabricate(:topic, category: subcategory) }
|
||||
|
||||
it 'updates last_seen_at for main category' do
|
||||
it 'dismisses topics for main category' do
|
||||
sign_in(user)
|
||||
category_user = CategoryUser.create!(category_id: category.id, user_id: user.id)
|
||||
subcategory_user = CategoryUser.create!(category_id: subcategory.id, user_id: user.id)
|
||||
|
||||
TopicTrackingState.expects(:publish_dismiss_new).with(user.id, category.id.to_s)
|
||||
|
||||
put "/topics/reset-new.json?category_id=#{category.id}"
|
||||
|
||||
expect(category_user.reload.last_seen_at).not_to be_nil
|
||||
expect(subcategory_user.reload.last_seen_at).to be_nil
|
||||
expect(DismissedTopicUser.where(user_id: user.id).pluck(:topic_id)).to eq([category_topic.id])
|
||||
end
|
||||
|
||||
it 'updates last_seen_at for main category and subcategories' do
|
||||
it 'dismisses topics for main category and subcategories' do
|
||||
sign_in(user)
|
||||
category_user = CategoryUser.create!(category_id: category.id, user_id: user.id)
|
||||
subcategory_user = CategoryUser.create!(category_id: subcategory.id, user_id: user.id)
|
||||
put "/topics/reset-new.json?category_id=#{category.id}&include_subcategories=true"
|
||||
|
||||
expect(category_user.reload.last_seen_at).not_to be_nil
|
||||
expect(subcategory_user.reload.last_seen_at).not_to be_nil
|
||||
expect(DismissedTopicUser.where(user_id: user.id).pluck(:topic_id).sort).to eq([category_topic.id, subcategory_topic.id].sort)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user