FIX: don't error out when updating a topic with no changes
This commit is contained in:
parent
9bdac79ba6
commit
f226e4efc0
|
@ -123,8 +123,8 @@ class TopicsController < ApplicationController
|
||||||
guardian.ensure_can_edit!(topic)
|
guardian.ensure_can_edit!(topic)
|
||||||
|
|
||||||
changes = {}
|
changes = {}
|
||||||
changes[:title] = params[:title] if params[:title]
|
changes[:title] = params[:title] if params[:title] && topic.title != params[:title]
|
||||||
changes[:category_id] = params[:category_id] if params[:category_id]
|
changes[:category_id] = params[:category_id] if params[:category_id] && topic.category_id != params[:category_id].to_i
|
||||||
|
|
||||||
success = true
|
success = true
|
||||||
|
|
||||||
|
|
|
@ -783,6 +783,12 @@ describe TopicsController do
|
||||||
expect(response).not_to be_success
|
expect(response).not_to be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't call the PostRevisor when there is no changes" do
|
||||||
|
PostRevisor.any_instance.expects(:revise!).never
|
||||||
|
xhr :put, :update, topic_id: @topic.id, slug: @topic.title, title: @topic.title, category_id: @topic.category_id
|
||||||
|
expect(response).to be_success
|
||||||
|
end
|
||||||
|
|
||||||
context "allow_uncategorized_topics is false" do
|
context "allow_uncategorized_topics is false" do
|
||||||
before do
|
before do
|
||||||
SiteSetting.stubs(:allow_uncategorized_topics).returns(false)
|
SiteSetting.stubs(:allow_uncategorized_topics).returns(false)
|
||||||
|
|
Loading…
Reference in New Issue