FEATURE: Add last visit indication to topic view page. (#13471)

This PR also removes grey old unread bubble from the topic badges by
dropping `TopicUser#highest_seen_post_number`.
This commit is contained in:
Alan Guo Xiang Tan
2021-07-05 14:17:31 +08:00
committed by GitHub
parent 0f688f45bd
commit 37b8ce79c9
64 changed files with 306 additions and 312 deletions

View File

@ -27,62 +27,45 @@ describe Unread do
describe 'staff counts' do
it 'should correctly return based on staff post number' do
user.admin = true
topic_user.last_read_post_number = 13
topic_user.highest_seen_post_number = 13
expect(unread.unread_posts).to eq(0)
expect(unread.new_posts).to eq(2)
expect(unread.unread_posts).to eq(2)
end
end
describe 'unread_posts' do
it 'should have 0 unread posts if the user has seen all posts' do
it 'should have 0 unread posts if the user has read all posts' do
topic_user.last_read_post_number = 13
topic_user.highest_seen_post_number = 13
expect(unread.unread_posts).to eq(0)
end
it 'should have 6 unread posts if the user has seen all but 6 posts' do
topic_user.last_read_post_number = 5
topic_user.highest_seen_post_number = 11
expect(unread.unread_posts).to eq(6)
it 'returns the right unread posts for a user' do
topic_user.last_read_post_number = 10
expect(unread.unread_posts).to eq(3)
end
it 'should have 0 unread posts if the user has seen more posts than exist (deleted)' do
topic_user.last_read_post_number = 100
topic_user.highest_seen_post_number = 13
it 'returns the right unread posts for a staff user' do
user.admin = true
topic_user.last_read_post_number = 10
expect(unread.unread_posts).to eq(5)
end
it 'should have 0 unread posts if the user has read more posts than exist (deleted)' do
topic_user.last_read_post_number = 14
expect(unread.unread_posts).to eq(0)
end
end
describe 'new_posts' do
it 'should have 0 new posts if the user has read all posts' do
topic_user.last_read_post_number = 13
expect(unread.new_posts).to eq(0)
end
it 'returns 0 when the topic is the same length as when you last saw it' do
topic_user.highest_seen_post_number = 13
expect(unread.new_posts).to eq(0)
end
it 'has 3 new posts if the user has read 10 posts' do
topic_user.highest_seen_post_number = 10
expect(unread.new_posts).to eq(3)
end
it 'has 0 new posts if the user has read 10 posts but is not tracking' do
topic_user.highest_seen_post_number = 10
it 'has 0 unread posts if the user has read 10 posts but is not tracking' do
topic_user.last_read_post_number = 10
topic_user.notification_level = TopicUser.notification_levels[:regular]
expect(unread.new_posts).to eq(0)
expect(unread.unread_posts).to eq(0)
end
it 'has 0 new posts if the user read more posts than exist (deleted)' do
topic_user.highest_seen_post_number = 16
expect(unread.new_posts).to eq(0)
it 'has 0 unread psots if the user has not seen the topic' do
topic_user.last_read_post_number = nil
expect(unread.unread_posts).to eq(0)
end
end