DEV: Make user field validation more specific (#16746)

- Only validate if custom_fields are loaded, so that we don't trigger a db query
- Only validate public user fields, not all custom_fields

This commit also reverts the unrelated spec changes in ba148e08, which were required to work around these issues
This commit is contained in:
David Taylor
2022-05-16 14:21:33 +01:00
committed by GitHub
parent b65ecf6987
commit 38216f6f0b
6 changed files with 29 additions and 15 deletions

View File

@ -289,9 +289,9 @@ describe UserAnonymizer do
"user_field_#{field2.id}": "bar",
"another_field": "456"
}
user.save
expect { make_anonymous }.to change { user.reload.custom_fields }.to "some_field" => "123", "another_field" => "456"
expect { make_anonymous }.to change { user.custom_fields }
expect(user.reload.custom_fields).to eq("some_field" => "123", "another_field" => "456")
end
end
end