mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
New interface to upsert custom fields
This commit is contained in:
@@ -215,5 +215,31 @@ describe HasCustomFields do
|
||||
test_item.save_custom_fields(true)
|
||||
expect(test_item.reload.custom_fields).to eq(expected)
|
||||
end
|
||||
|
||||
describe "upsert_custom_fields" do
|
||||
it 'upserts records' do
|
||||
test_item = CustomFieldsTestItem.create
|
||||
test_item.upsert_custom_fields('hello' => 'world', 'abc' => 'def')
|
||||
|
||||
# In memory
|
||||
expect(test_item.custom_fields['hello']).to eq('world')
|
||||
expect(test_item.custom_fields['abc']).to eq('def')
|
||||
|
||||
# Persisted
|
||||
test_item.reload
|
||||
expect(test_item.custom_fields['hello']).to eq('world')
|
||||
expect(test_item.custom_fields['abc']).to eq('def')
|
||||
|
||||
# In memory
|
||||
test_item.upsert_custom_fields('abc' => 'ghi')
|
||||
expect(test_item.custom_fields['hello']).to eq('world')
|
||||
expect(test_item.custom_fields['abc']).to eq('ghi')
|
||||
|
||||
# Persisted
|
||||
test_item.reload
|
||||
expect(test_item.custom_fields['hello']).to eq('world')
|
||||
expect(test_item.custom_fields['abc']).to eq('ghi')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user