mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-24 16:18:42 -05:00
b3d769ff4f
update rspec syntax to v3 change syntax to rspec v3 oops. fix typo mailers classes with rspec3 syntax helpers with rspec3 syntax jobs with rspec3 syntax serializers with rspec3 syntax views with rspec3 syntax support to rspec3 syntax category spec with rspec3 syntax
45 lines
1.3 KiB
Ruby
45 lines
1.3 KiB
Ruby
# encoding: UTF-8
|
|
|
|
require 'spec_helper'
|
|
require_dependency 'post_destroyer'
|
|
|
|
describe TopicStatusUpdate do
|
|
|
|
let(:user) { Fabricate(:user) }
|
|
let(:admin) { Fabricate(:admin) }
|
|
|
|
it "avoids notifying on automatically closed topics" do
|
|
# TODO: TopicStatusUpdate should supress message bus updates from the users it "pretends to read"
|
|
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
|
|
|
|
TopicStatusUpdate.new(post.topic, admin).update!("autoclosed", true)
|
|
|
|
expect(post.topic.posts.count).to eq(2)
|
|
|
|
tu = TopicUser.find_by(user_id: user.id)
|
|
expect(tu.last_read_post_number).to eq(2)
|
|
end
|
|
|
|
it "adds an autoclosed message" do
|
|
topic = create_topic
|
|
|
|
TopicStatusUpdate.new(topic, admin).update!("autoclosed", true)
|
|
|
|
expect(topic.posts.last.raw).to eq(I18n.t("topic_statuses.autoclosed_enabled_minutes", count: 0))
|
|
end
|
|
|
|
it "adds an autoclosed message based on last post" do
|
|
topic = create_topic
|
|
topic.auto_close_based_on_last_post = true
|
|
|
|
TopicStatusUpdate.new(topic, admin).update!("autoclosed", true)
|
|
|
|
expect(topic.posts.last.raw).to eq(I18n.t("topic_statuses.autoclosed_enabled_lastpost_minutes", count: 0))
|
|
end
|
|
|
|
end
|