diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-07-15 19:21:02 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-07-15 19:21:02 +0000 |
commit | 3b9e58953f5e846280d7f14a87a9816c24c1cc8d (patch) | |
tree | 78ccdc3e7343c8a3ef375f57ecdf27a2e3a32ce5 /app/mailers | |
parent | 263f005e905088dc7b84276f0a14be567fd158b0 (diff) | |
parent | efe18f0507e08c7fd0f90a99e0c241c3c4ce107a (diff) | |
download | gitlab-ce-3b9e58953f5e846280d7f14a87a9816c24c1cc8d.tar.gz |
Merge branch 'fix-mentioned-users-on-diff-notes' into 'master'
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
Diffstat (limited to 'app/mailers')
0 files changed, 0 insertions, 0 deletions