mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 00:08:53 +08:00
FIX: do not use return in block (#26260)
We were incorrectly using `return` in a block which was causing exceptions at runtime. These exceptions were not causing much issues as they are in defer block. While working on writing a test for this specific case, I noticed that our `upsert_custom_fields` function was using rails `update_all` which is not updating the `updated_at` timestamp. This commit also fixes it and adds a test for it.
This commit is contained in:
@ -459,6 +459,17 @@ RSpec.describe HasCustomFields do
|
||||
expect(test_item.custom_fields["abc"]).to eq("ghi")
|
||||
end
|
||||
|
||||
it "updates the updated_at timestamp" do
|
||||
test_item = CustomFieldsTestItem.create
|
||||
test_item.upsert_custom_fields(foo: "bar")
|
||||
field = CustomFieldsTestItemCustomField.find_by(name: "foo")
|
||||
prev_updated_at = field.updated_at
|
||||
|
||||
test_item.upsert_custom_fields(foo: "baz")
|
||||
|
||||
expect(prev_updated_at).not_to eq(field.reload.updated_at)
|
||||
end
|
||||
|
||||
it "allows upsert to use keywords" do
|
||||
test_item = CustomFieldsTestItem.create
|
||||
test_item.upsert_custom_fields(hello: "world", abc: "def")
|
||||
|
Reference in New Issue
Block a user