Refactor #34569
closedPostpone LookupValue match validations
Description
match gets overriden by Rails if the record has been build by association e.g. `host.lookup_values.build()`
That basically means that any assigned value to match prior save is irrelevant because it will be replaced by Rails.
This was never an issue, because Rails just replaced the value with the same value as we've assigned, so it went unnoticed.
It only starts to cause issues once Rails had fixed a bug where it wrongly allowed foreign_key to be passed to <assoc>.build(foreign_key => value)
This is for sym vs string in hash keys as in https://github.com/rails/rails/blob/13cdd7a6aef86b23c3410adff1d4f6eeefc72c67/activerecord/lib/active_record/associations/association.rb#L196 reflection.foreign_key returned a symbol, but attribute is a string, so the assigned foreign key did not get filtered out properly.
This bug had been fixed in Rails 6.1 and the assigned foreign key is filtered out properly and our validations fail on presence of match as that gets assigned from host only after the Host is saved and thats after validation.
Updated by The Foreman Bot over 2 years ago
- Status changed from New to Ready For Testing
- Assignee set to Ondřej Ezr
- Pull request https://github.com/theforeman/foreman/pull/9137 added
Updated by Ondřej Ezr over 2 years ago
- Blocks Tracker #28570: Rails 6.1 Tracker added
Updated by Ondřej Ezr over 2 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset foreman|5a77b476fca4ae005b0edfe15647f55ce7a42ad5.