Project

General

Profile

Actions

Bug #18540

closed

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

Added by Dominic Cleal about 7 years ago. Updated over 5 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 #1

Updated by The Foreman Bot about 7 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4296 added
Actions #2

Updated by Dominic Cleal about 7 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #3

Updated by Dominic Cleal about 7 years ago

  • translation missing: en.field_release set to 209
Actions

Also available in: Atom PDF