Commit f38c7780 authored by Ohad Dahan's avatar Ohad Dahan

Merge branch '196371' of gitlab.com:ohaddahan/gitlab into 196371

parents 71714a0f 8f7c5746
......@@ -186,7 +186,11 @@ class Namespace < ApplicationRecord
# any ancestor can disable emails for all descendants
def emails_disabled?
strong_memoize(:emails_disabled) do
if parent_id
self_and_ancestors.where(emails_disabled: true).exists?
else
!!emails_disabled
end
end
end
......
......@@ -923,6 +923,12 @@ describe Namespace do
expect(group.emails_disabled?).to be_truthy
end
it 'not query the db when there is no parent group' do
group = create(:group, emails_disabled: true)
expect { group.emails_disabled? }.not_to exceed_query_limit(0)
end
end
context 'when a subgroup' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment