mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -06:00
FIX: allows to remove a topic timer with delete_replies as type (#9800)
This commit is contained in:
parent
d01c336899
commit
918bd75909
@ -445,7 +445,7 @@ class TopicsController < ApplicationController
|
||||
invalid_param(:status_type)
|
||||
end
|
||||
based_on_last_post = params[:based_on_last_post]
|
||||
params.require(:duration) if based_on_last_post || TopicTimer.types[:delete_replies] == status_type
|
||||
params.require(:duration) if based_on_last_post
|
||||
|
||||
topic = Topic.find_by(id: params[:topic_id])
|
||||
guardian.ensure_can_moderate!(topic)
|
||||
|
@ -2709,6 +2709,24 @@ RSpec.describe TopicsController do
|
||||
expect(json['duration']).to eq(topic_status_update.duration)
|
||||
end
|
||||
|
||||
it 'should be able to delete a topic status update for delete_replies type' do
|
||||
Fabricate(:topic_timer, topic: topic, status_type: TopicTimer.types[:delete_replies])
|
||||
|
||||
post "/t/#{topic.id}/timer.json", params: {
|
||||
time: nil,
|
||||
status_type: TopicTimer.types[7]
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(topic.reload.public_topic_timer).to eq(nil)
|
||||
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json['execute_at']).to eq(nil)
|
||||
expect(json['duration']).to eq(nil)
|
||||
expect(json['closed']).to eq(topic.closed)
|
||||
end
|
||||
|
||||
describe 'publishing topic to category in the future' do
|
||||
it 'should be able to create the topic status update' do
|
||||
post "/t/#{topic.id}/timer.json", params: {
|
||||
|
Loading…
Reference in New Issue
Block a user