Commit a65e4549 authored by Jackie Fraser's avatar Jackie Fraser

Fix empty recursive query for base_and_ancestors

Changelog: fixed
parent 3399b4c5
......@@ -1005,6 +1005,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
......
......@@ -4002,6 +4002,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
......@@ -4263,6 +4271,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