提交 8d4cc9cb 编写于 作者: M Michael Kozono

Fixes #32474

Older namespace records may be both `type == ‘Group` AND `owner_id` is not null.
上级 0b946a7b
......@@ -351,7 +351,9 @@ class User < ActiveRecord::Base
def find_by_full_path(path, follow_redirects: false)
namespace = Namespace.find_by_full_path(path, follow_redirects: follow_redirects)
namespace&.owner
return unless namespace && namespace.kind == 'user'
namespace.owner
end
def reference_prefix
......
......@@ -929,6 +929,15 @@ describe User, models: true do
end
context 'with a group route matching the given path' do
context 'when the group namespace has an owner_id (legacy data)' do
let!(:group) { create(:group, path: 'group_path', owner: user) }
it 'returns nil' do
expect(User.find_by_full_path('group_path')).to eq(nil)
end
end
context 'when the group namespace does not have an owner_id' do
let!(:group) { create(:group, path: 'group_path') }
it 'returns nil' do
......@@ -936,6 +945,7 @@ describe User, models: true do
end
end
end
end
describe 'all_ssh_keys' do
it { is_expected.to have_many(:keys).dependent(:destroy) }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册