Project

General

Profile

Actions

Bug #19541

closed

UserMailNotification records are not set up properly when a mail notification is added.

Added by Shimon Shtein over 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Rails
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

When assigning one-to-many associations we should use after(:create) hook to add those associations properly.

Actions #1

Updated by The Foreman Bot over 7 years ago

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

Updated by Ivan Necas over 7 years ago

  • Target version set to 1.13.3
Actions #3

Updated by Shimon Shtein over 7 years ago

  • Subject changed from Fix user factory's :with_mail_notification trait to UserMailNotification records are not set up properly when a mail notification is added.

When using new in-memory objects, the association objects are not set up correctly without :inverse_of option.

to reproduce:

User.new(:login => 'zzz', :mail_notifications => [MailNotification.new]).user_mail_notifications.first.user

This statement will return nil, but should return a reference to the newly created user.
This happens due to the fact that inverse_of is not set.
After setting proper inverse_of, Active Record will point UserMailNotification#user property to the newly created user in this example.

Actions #4

Updated by Dominic Cleal over 7 years ago

  • Category set to Rails
Actions #5

Updated by Shimon Shtein over 7 years ago

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

Updated by Marek Hulán over 7 years ago

  • Translation missing: en.field_release set to 240
Actions

Also available in: Atom PDF