mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
FIX: "Dismiss Posts" corrupting read state
REFACTOR: seen_post_count was a bad name, renamed to highest_seen_post_number
This commit is contained in:
@ -16,19 +16,19 @@ describe Unread do
|
||||
describe 'unread_posts' do
|
||||
it 'should have 0 unread posts if the user has seen all posts' do
|
||||
@topic_user.stubs(:last_read_post_number).returns(13)
|
||||
@topic_user.stubs(:seen_post_count).returns(13)
|
||||
@topic_user.stubs(:highest_seen_post_number).returns(13)
|
||||
@unread.unread_posts.should == 0
|
||||
end
|
||||
|
||||
it 'should have 6 unread posts if the user has seen all but 6 posts' do
|
||||
@topic_user.stubs(:last_read_post_number).returns(5)
|
||||
@topic_user.stubs(:seen_post_count).returns(11)
|
||||
@topic_user.stubs(:highest_seen_post_number).returns(11)
|
||||
@unread.unread_posts.should == 6
|
||||
end
|
||||
|
||||
it 'should have 0 unread posts if the user has seen more posts than exist (deleted)' do
|
||||
@topic_user.stubs(:last_read_post_number).returns(100)
|
||||
@topic_user.stubs(:seen_post_count).returns(13)
|
||||
@topic_user.stubs(:highest_seen_post_number).returns(13)
|
||||
@unread.unread_posts.should == 0
|
||||
end
|
||||
end
|
||||
@ -40,23 +40,23 @@ describe Unread do
|
||||
end
|
||||
|
||||
it 'returns 0 when the topic is the same length as when you last saw it' do
|
||||
@topic_user.stubs(:seen_post_count).returns(13)
|
||||
@topic_user.stubs(:highest_seen_post_number).returns(13)
|
||||
@unread.new_posts.should == 0
|
||||
end
|
||||
|
||||
it 'has 3 new posts if the user has read 10 posts' do
|
||||
@topic_user.stubs(:seen_post_count).returns(10)
|
||||
@topic_user.stubs(:highest_seen_post_number).returns(10)
|
||||
@unread.new_posts.should == 3
|
||||
end
|
||||
|
||||
it 'has 0 new posts if the user has read 10 posts but is not tracking' do
|
||||
@topic_user.stubs(:seen_post_count).returns(10)
|
||||
@topic_user.stubs(:highest_seen_post_number).returns(10)
|
||||
@topic_user.stubs(:notification_level).returns(TopicUser.notification_levels[:regular])
|
||||
@unread.new_posts.should == 0
|
||||
end
|
||||
|
||||
it 'has 0 new posts if the user read more posts than exist (deleted)' do
|
||||
@topic_user.stubs(:seen_post_count).returns(16)
|
||||
@topic_user.stubs(:highest_seen_post_number).returns(16)
|
||||
@unread.new_posts.should == 0
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user