A platform for community discussion. Free, open, simple.
FIX: allows to remove a topic timer with delete_replies as type (#9800)
Joffrey JAFFEUX918bd75909d7
diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rbindex 954369af278..211e94ce8df 100644--- a/app/controllers/topics_controller.rb+++ b/app/controllers/topics_controller.rb@@ -445,7 +445,7 @@ class TopicsController < ApplicationControllerinvalid_param(:status_type)endbased_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_posttopic = Topic.find_by(id: params[:topic_id])guardian.ensure_can_moderate!(topic)diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rbindex cf4f5f15b4f..726b92228f2 100644--- a/spec/requests/topics_controller_spec.rb+++ b/spec/requests/topics_controller_spec.rb@@ -2709,6 +2709,24 @@ RSpec.describe TopicsController doexpect(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' doit 'should be able to create the topic status update' dopost "/t/#{topic.id}/timer.json", params: {