Skip to content
代码片段 群组 项目
提交 0374323c 编辑于 作者: Jessie Young's avatar Jessie Young 提交者: Kerri Miller
浏览文件

Fix bug in U2fRegistration after_update callback

* In a pipeline for a separate MR, rspec undercover flagged that
  this was not tested: https://gitlab.com/gitlab-org/gitlab/-/jobs/2778676259
* Specs for the existing behavior revealed that this callback was not
  called as expected due to the activerecord dirty condition
* In ActiveRecord 5.1, the following deprecation message was added:

    DEPRECATION WARNING: The behavior of `attribute_changed?` inside of
    after callbacks will be changing in the next version of Rails. The new
    return value will reflect the behavior of calling the method after
    `save` returned (e.g. the opposite of what it returns now). To maintain
    the current behavior, use `saved_change_to_attribute?` instead.

* Starting with Rails 5.2 (we are currently on Rails 6.1.6.1), within an
  `after_update` callback, `attribute_changed?` now returns `false` even
  if the attribute was changed.
* So in this case, changes to the `counter` attribute were not
  triggering this callback.
* Updating the callback to `saved_change_to_<attribute>` fixes the
  issue: https://github.com/rails/rails/blob/04972d9b9ef60796dc8f0917817b5392d61fcf09/activerecord/lib/active_record/attribute_methods/dirty.rb#L86-L92
上级 b57d859c
加载中
加载中
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册