mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 12:51:24 +08:00
FIX: Editing a topic's title should be rate limited too.
This commit is contained in:
@ -129,6 +129,7 @@ class TopicsController < ApplicationController
|
|||||||
Topic.transaction do
|
Topic.transaction do
|
||||||
success = topic.save
|
success = topic.save
|
||||||
success &= topic.change_category_to_id(params[:category_id].to_i) unless topic.private_message?
|
success &= topic.change_category_to_id(params[:category_id].to_i) unless topic.private_message?
|
||||||
|
EditRateLimiter.new(current_user).performed!
|
||||||
end
|
end
|
||||||
|
|
||||||
# this is used to return the title to the client as it may have been changed by "TextCleaner"
|
# this is used to return the title to the client as it may have been changed by "TextCleaner"
|
||||||
|
@ -770,6 +770,12 @@ describe TopicsController do
|
|||||||
expect(response).not_to be_success
|
expect(response).not_to be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns errors when the rate limit is exceeded" do
|
||||||
|
EditRateLimiter.any_instance.expects(:performed!).raises(RateLimiter::LimitExceeded.new(60))
|
||||||
|
xhr :put, :update, topic_id: @topic.id, slug: @topic.title, title: 'This is a new title for the topic'
|
||||||
|
response.should_not be_success
|
||||||
|
end
|
||||||
|
|
||||||
it "returns errors with invalid categories" do
|
it "returns errors with invalid categories" do
|
||||||
Topic.any_instance.expects(:change_category_to_id).returns(false)
|
Topic.any_instance.expects(:change_category_to_id).returns(false)
|
||||||
xhr :put, :update, topic_id: @topic.id, slug: @topic.title
|
xhr :put, :update, topic_id: @topic.id, slug: @topic.title
|
||||||
|
Reference in New Issue
Block a user