Commit eb46b11c authored by James Fargher's avatar James Fargher

Merge branch 'fix_empty_recursive_query_for_base_and_ancestors' into 'master'

Fix empty recursive query for base_and_ancestors

See merge request gitlab-org/gitlab!67182
parents de0c2a54 a65e4549
......@@ -1013,6 +1013,8 @@ class User < ApplicationRecord
# Returns a relation of groups the user has access to, including their parent
# and child groups (recursively).
def all_expanded_groups
return groups if groups.empty?
Gitlab::ObjectHierarchy.new(groups).all_objects
end
......
......@@ -4039,6 +4039,14 @@ RSpec.describe User do
]
end
end
context 'when the user is not saved' do
let(:user) { build(:user) }
it 'returns empty when there are no groups or ancestor groups for the user' do
is_expected.to eq([])
end
end
end
describe '#refresh_authorized_projects', :clean_gitlab_redis_shared_state do
......@@ -4300,6 +4308,14 @@ RSpec.describe User do
expect(user.two_factor_grace_period).to be 48
end
end
context 'when the user is not saved' do
let(:user) { build(:user) }
it 'does not raise an ActiveRecord::StatementInvalid statement exception' do
expect { user.update_two_factor_requirement }.not_to raise_error
end
end
end
describe '#source_groups_of_two_factor_authentication_requirement' 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