mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-03-22 04:45:46 -04:00
FIX: Editing a topic's title should be rate limited too.
This commit is contained in:
parent
11b52d1334
commit
2fbfc9dffa
2 changed files with 7 additions and 0 deletions
|
@ -129,6 +129,7 @@ class TopicsController < ApplicationController
|
|||
Topic.transaction do
|
||||
success = topic.save
|
||||
success &= topic.change_category_to_id(params[:category_id].to_i) unless topic.private_message?
|
||||
EditRateLimiter.new(current_user).performed!
|
||||
end
|
||||
|
||||
# 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
|
||||
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
|
||||
Topic.any_instance.expects(:change_category_to_id).returns(false)
|
||||
xhr :put, :update, topic_id: @topic.id, slug: @topic.title
|
||||
|
|
Loading…
Reference in a new issue