mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Auto close topic from category settings based on topic created_at (#12082)
Previously when inheriting category auto-close settings for a topic, those settings were disrupted if another topic timer was assigned or if a topic was closed then manually re-opened. This PR makes it so that when a topic is manually re-opened the topic auto-close settings are inherited from the category. However, they will now be based on the topic created_at date. As an example, for a topic with a category auto close hours setting of 72 (3 days): * Topic was created on 2021-02-15 08:00 * Topic was closed on 2021-02-16 10:00 * Topic was opened again on 2021-02-17 06:00 Now, the topic will inherit the auto close timer again and will close automatically at **2021-02-18 08:00**, which is based on the creation date. If the current date and time is greater than the original auto-close time (e.g. we were at 2021-02-20 13:45) then no auto-close timer is created. Note, this will not happen if the topic category auto-close setting is "based on last post".
This commit is contained in:
@@ -41,7 +41,7 @@ describe Topic do
|
||||
topic_status_update = TopicTimer.last
|
||||
|
||||
expect(topic_status_update.topic).to eq(topic)
|
||||
expect(topic.public_topic_timer.execute_at).to eq_time(2.hours.from_now)
|
||||
expect(topic.public_topic_timer.execute_at).to be_within_one_second_of(2.hours.from_now)
|
||||
end
|
||||
|
||||
context 'topic was created by staff user' do
|
||||
@@ -54,7 +54,7 @@ describe Topic do
|
||||
topic_status_update = TopicTimer.last
|
||||
|
||||
expect(topic_status_update.topic).to eq(staff_topic)
|
||||
expect(topic_status_update.execute_at).to eq_time(2.hours.from_now)
|
||||
expect(topic_status_update.execute_at).to be_within_one_second_of(2.hours.from_now)
|
||||
expect(topic_status_update.user).to eq(Discourse.system_user)
|
||||
end
|
||||
|
||||
@@ -65,7 +65,7 @@ describe Topic do
|
||||
staff_topic.update_status('closed', true, admin)
|
||||
|
||||
expect(TopicTimer.with_deleted.find(topic_timer_id).deleted_at)
|
||||
.to eq_time(Time.zone.now)
|
||||
.to be_within_one_second_of(Time.zone.now)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -80,7 +80,7 @@ describe Topic do
|
||||
topic_status_update = TopicTimer.last
|
||||
|
||||
expect(topic_status_update.topic).to eq(regular_user_topic)
|
||||
expect(topic_status_update.execute_at).to eq_time(2.hours.from_now)
|
||||
expect(topic_status_update.execute_at).to be_within_one_second_of(2.hours.from_now)
|
||||
expect(topic_status_update.user).to eq(Discourse.system_user)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user