FIX: insert different message when auto-closing a topic based on the last post

This commit is contained in:
Régis Hanol
2014-10-29 21:26:32 +01:00
parent 62fa3775f2
commit 7e94f9d6f9
4 changed files with 56 additions and 24 deletions

View File

@ -4,18 +4,19 @@ 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"
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
# 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
@ -23,4 +24,22 @@ describe TopicStatusUpdate do
tu = TopicUser.find_by(user_id: user.id)
tu.last_read_post_number.should == 2
end
it "adds an autoclosed message" do
topic = create_topic
TopicStatusUpdate.new(topic, admin).update!("autoclosed", true)
topic.posts.last.raw.should == 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)
topic.posts.last.raw.should == I18n.t("topic_statuses.autoclosed_enabled_lastpost_minutes", count: 0)
end
end