Commit 355c64fb authored by Alper Akgun's avatar Alper Akgun

Merge branch 'nicolasdular/fix-in-product-marketing-crash' into 'master'

Fix crashing in-product-marketing email worker

See merge request gitlab-org/gitlab!56381
parents 6775651e 96ada461
......@@ -63,7 +63,10 @@ module Namespaces
.completed_actions_with_latest_in_range(completed_actions, range)
.incomplete_actions(incomplete_action)
Group.joins(:onboarding_progress).merge(onboarding_progress_scope)
# Filtering out sub-groups is a temporary fix to prevent calling
# `.root_ancestor` on groups that are not root groups.
# See https://gitlab.com/groups/gitlab-org/-/epics/5594 for more information.
Group.where(parent_id: nil).joins(:onboarding_progress).merge(onboarding_progress_scope)
end
def users_for_group(group)
......
......@@ -159,4 +159,20 @@ RSpec.describe Namespaces::InProductMarketingEmailsService, '#execute' do
it { expect { subject }.to raise_error(NotImplementedError, 'No ability defined for track foo') }
end
context 'when group is a sub-group' do
let(:root_group) { create(:group) }
let(:group) { create(:group) }
before do
group.parent = root_group
group.save!
allow(Ability).to receive(:allowed?).and_call_original
end
it 'does not raise an exception' do
expect { execute_service }.not_to raise_error
end
end
end
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