BigW Consortium Gitlab
Fix mentioned users on diff notes ## Summary `DiffNote`, and `LegacyDiffNote` returns empty array for `mentionable_attrs`, because `mentionable_attrs` is not inheritable by subclasses. The problem can be illustrated with this small sample: ```ruby module Mentionable extend ActiveSupport::Concern module ClassMethods def attr_mentionable(attr) mentionable_attrs << [attr.to_s] end def mentionable_attrs @mentionable_attrs ||= [] end end end class A include Mentionable attr_mentionable :foo end class B < A end A.mentionable_attrs => [["foo", {}]] B.mentionable_attrs => [] ``` Possible solution using `cattr_accessor`: ```ruby module Mentionable extend ActiveSupport::Concern module ClassMethods def attr_mentionable(attr) mentionable_attrs << [attr.to_s] end end included do cattr_accessor :mentionable_attrs, instance_accessor: false do [] end end end class A include Mentionable attr_mentionable :foo end class B < A end A.mentionable_attrs => [["foo"]] B.mentionable_attrs => [["foo"]] B.mentionable_attrs < [:bar] => [["foo"], ["bar"]] A.mentionable_attrs => [["foo"], ["bar"]] ``` `mentionable_attrs` is inheritable by subclasses. If a subclass changes the value then that would also change the value for parent class. Similarly if parent class changes the value then that would change the value of subclasses too. ## What are the relevant issue numbers? Fixes #19807 Fixes #18022 /cc @stanhu @DouweM @rspeicher See merge request !5243
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
access_requestable.rb | Loading commit data... | |
awardable.rb | Loading commit data... | |
case_sensitivity.rb | Loading commit data... | |
importable.rb | Loading commit data... | |
internal_id.rb | Loading commit data... | |
issuable.rb | Loading commit data... | |
mentionable.rb | Loading commit data... | |
milestoneish.rb | Loading commit data... | |
note_on_diff.rb | Loading commit data... | |
participable.rb | Loading commit data... | |
referable.rb | Loading commit data... | |
sortable.rb | Loading commit data... | |
statuseable.rb | Loading commit data... | |
strip_attribute.rb | Loading commit data... | |
subscribable.rb | Loading commit data... | |
taskable.rb | Loading commit data... | |
token_authenticatable.rb | Loading commit data... |