FIX: Do not attempt to serialize Tag objects when tagging disabled (#18264)
When tagging is enabled, we were correctly serializing tags by their name. However, when tagging was disabled we were attempting to serialize an entire Tag object which raises an error since ee07f6da7d
.
https://meta.discourse.org/t/232885
This commit is contained in:
parent
87f8bafa7e
commit
3e8b6c67ea
|
@ -208,6 +208,7 @@ class PostRevisionSerializer < ApplicationSerializer
|
||||||
|
|
||||||
# Retrieve any `tracked_topic_fields`
|
# Retrieve any `tracked_topic_fields`
|
||||||
PostRevisor.tracked_topic_fields.each_key do |field|
|
PostRevisor.tracked_topic_fields.each_key do |field|
|
||||||
|
next if field == :tags # Special handling below
|
||||||
if topic.respond_to?(field)
|
if topic.respond_to?(field)
|
||||||
latest_modifications[field.to_s] = [topic.public_send(field)]
|
latest_modifications[field.to_s] = [topic.public_send(field)]
|
||||||
end
|
end
|
||||||
|
|
|
@ -1750,6 +1750,23 @@ RSpec.describe PostsController do
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with a tagged topic" do
|
||||||
|
let(:tag) { Fabricate(:tag) }
|
||||||
|
it "works" do
|
||||||
|
SiteSetting.tagging_enabled = true
|
||||||
|
|
||||||
|
post_revision.post.topic.update(tags: [tag])
|
||||||
|
|
||||||
|
get "/posts/#{post_revision.post_id}/revisions/latest.json"
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
|
SiteSetting.tagging_enabled = false
|
||||||
|
|
||||||
|
get "/posts/#{post_revision.post_id}/revisions/latest.json"
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#revert' do
|
describe '#revert' do
|
||||||
|
|
Loading…
Reference in New Issue