Project

General

Profile

Actions

Bug #18540

closed

Host#update_attribute(domain: ...) tests fail on Rails 5, model not saved

Added by Dominic Cleal almost 8 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Tests
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

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.

Actions

Also available in: Atom PDF