discourse/spec/models/topic_status_update_spec.rb

27 lines
796 B
Ruby

# encoding: UTF-8
require 'spec_helper'
require_dependency 'post_destroyer'
describe TopicStatusUpdate do
it "avoids notifying on automatically closed topics" do
# TODO: TopicStatusUpdate should supress message bus updates from the users it "pretends to read"
user = Fabricate(:user)
post = PostCreator.create(user,
raw: "this is a test post 123 this is a test post",
title: "hello world title",
)
# TODO needed so counts sync up,
# PostCreator really should not give back out-of-date Topic
post.topic.reload
admin = Fabricate(:admin)
TopicStatusUpdate.new(post.topic, admin).update!("autoclosed", true)
post.topic.posts.count.should == 2
tu = TopicUser.find_by(user_id: user.id)
tu.last_read_post_number.should == 2
end
end