2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 09:10:25 +08:00

Revert unread optimisation, has too many edge cases

This commit is contained in:
Sam 2017-05-26 09:04:13 -04:00
parent 4d9481bf47
commit 0aed2533ac
12 changed files with 26 additions and 159 deletions

View file

@ -38,36 +38,6 @@ describe TopicUser do
end
describe "first unread" do
it "correctly update first unread as needed" do
time1 = 3.days.ago
time2 = 2.days.ago
time3 = 1.days.ago
topic1 = Fabricate(:topic, last_unread_at: time1)
topic2 = Fabricate(:topic, last_unread_at: time2)
topic3 = Fabricate(:topic, last_unread_at: time3)
user = Fabricate(:user)
user.user_stat.update_columns(first_topic_unread_at: Time.zone.now)
TopicUser.change(user.id, topic3, notification_level: tracking)
user.user_stat.reload
expect(user.user_stat.first_topic_unread_at).to be_within(1.second).of(time3)
TopicUser.change(user.id, topic2, notification_level: watching)
user.user_stat.reload
expect(user.user_stat.first_topic_unread_at).to be_within(1.second).of(time2)
TopicUser.change(user.id, topic1, notification_level: regular)
user.user_stat.reload
expect(user.user_stat.first_topic_unread_at).to be_within(1.second).of(time2)
end
end
describe '#notification_levels' do
context "verify enum sequence" do
before do

View file

@ -10,34 +10,6 @@ describe UserStat do
expect(user.user_stat.new_since).to be_present
end
context "#update_first_topic_unread_at" do
it "updates date correctly for staff" do
now = Time.zone.now
admin = Fabricate(:admin)
topic = Fabricate(:topic,
highest_staff_post_number: 7,
highest_post_number: 1,
last_unread_at: now
)
UserStat.update_first_topic_unread_at!
admin.reload
expect(admin.user_stat.first_topic_unread_at).to_not be_within(5.years).of(now)
TopicUser.change(admin.id, topic.id, last_read_post_number: 1,
notification_level: NotificationLevels.all[:tracking])
UserStat.update_first_topic_unread_at!
admin.reload
expect(admin.user_stat.first_topic_unread_at).to be_within(1.second).of(now)
end
end
context '#update_view_counts' do
let(:user) { Fabricate(:user) }