mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FIX: allow both meta_data and custom_fields when creating a topic
For some reasons, we have two ways of associating "custom fields" to a new topic: using 'meta_data' and 'custom_fields'. However, if we were to provide both arguments, the 'meta_data' would be overwritten by any 'custom_fields' provided. This commit ensures we can use both and merges the 'custom_fields' with the 'meta_data'.
This commit is contained in:
@ -36,6 +36,18 @@ describe TopicCreator do
|
||||
expect(TopicCreator.create(moderator, Guardian.new(moderator), valid_attrs)).to be_valid
|
||||
end
|
||||
|
||||
it "supports both meta_data and custom_fields" do
|
||||
opts = valid_attrs.merge(
|
||||
meta_data: { import_topic_id: "foo" },
|
||||
custom_fields: { import_id: "bar" }
|
||||
)
|
||||
|
||||
topic = TopicCreator.create(admin, Guardian.new(admin), opts)
|
||||
|
||||
expect(topic.custom_fields["import_topic_id"]).to eq("foo")
|
||||
expect(topic.custom_fields["import_id"]).to eq("bar")
|
||||
end
|
||||
|
||||
context 'regular user' do
|
||||
before { SiteSetting.min_trust_to_create_topic = TrustLevel[0] }
|
||||
|
||||
|
Reference in New Issue
Block a user