discourse/spec/models/topic_status_update_spec.rb
Louis Rose 1574485443 Perform the where(...).first to find_by(...) refactoring.
This refactoring was automated using the command: bundle exec "ruby refactorings/where_dot_first_to_find_by/app.rb"
2014-05-06 14:41:59 +01:00

29 lines
940 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
# TODO: also annoying PostTiming is not logged
PostTiming.create!(topic_id: post.topic_id, user_id: user.id, post_number: 1, msecs: 0)
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