mirror of
https://github.com/discourse/discourse-data-explorer.git
synced 2025-07-24 06:43:38 +00:00
FIX: Add new attribute that is required when using the basic topic serializer (#375)
In discourse/discourse#32618 we added the dependency on locales to the basic topic serializer gated behind SiteSetting.experimental_content_localization. This is so that fancy_titles can be rendered in the language of the user. Error: `ActiveModel::MissingAttributeError (missing attribute 'locale' for Topic)` This commit adds that dependency to extra_data_pluck_fields which lists fields required from the serializer.
This commit is contained in:
parent
ca9f0e07cb
commit
a0a7f8d999
@ -115,7 +115,7 @@ module ::DiscourseDataExplorer
|
||||
},
|
||||
topic: {
|
||||
class: Topic,
|
||||
fields: %i[id title slug posts_count],
|
||||
fields: %i[id title slug posts_count locale],
|
||||
serializer: BasicTopicSerializer,
|
||||
},
|
||||
group: {
|
||||
|
@ -87,6 +87,21 @@ describe DiscourseDataExplorer::DataExplorer do
|
||||
_, colrender = DiscourseDataExplorer::DataExplorer.add_extra_data(result[:pg_result])
|
||||
expect(colrender).to eq({ 1 => "json" })
|
||||
end
|
||||
|
||||
describe "serializing models to serializer" do
|
||||
it "serializes correctly to BasicTopicSerializer for topic relations" do
|
||||
topic = Fabricate(:topic, locale: "ja")
|
||||
query = Fabricate(:query, sql: "SELECT id AS topic_id FROM topics WHERE id = #{topic.id}")
|
||||
|
||||
pg_result = described_class.run_query(query)[:pg_result]
|
||||
relations, _ = DiscourseDataExplorer::DataExplorer.add_extra_data(pg_result)
|
||||
|
||||
expect {
|
||||
records = relations[:topic].object
|
||||
records.map { |t| BasicTopicSerializer.new(t, root: false).as_json }
|
||||
}.not_to raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user