Host#update_attribute(domain: ...) tests fail on Rails 5, model not saved
Tests that update a host's domain via update_attribute fail on Rails 5, e.g.
Failure: DomainTest#test_0011_should update hosts_count on domain_id change [/home/dcleal/code/foreman/foreman/test/models/domain_test.rb:118]: "@domain.hosts_count" didn't change by -1. Expected: 0 Actual: 1
The attribute isn't actually on Host::Managed, but the primary Nic via a delegation of #domain= to the primary_interface. Rails 5 has an optimisation in update_attribute that skips the #save when the model's not changed (https://github.com/rails/rails/commit/0fcd4cf) so the change doesn't trigger a save.
The tests should either call #domain= and #save themselves instead of using #update_attribute for this non-attribute, or change the domain attribute on the interface.
fixes #18540 - update domain on primary in hosts_count tests
domain/domain_id are not attributes of the host itself, they're
delegated to the primary interface. When using update_attribute on the
host, the model doesn't appear `changed?` so Rails 5 skips the save.
The test "should update hosts_count" is left with delegation as the
direct interface modification is tested in the next test.