Skip to content
Snippets Groups Projects
Commit 03e782d0 authored by Michael Kozono's avatar Michael Kozono
Browse files

Fix #1843

Older namespace records may be both `type == ‘Group` AND `owner_id` is not null.
parent 0b946a7b
No related branches found
No related tags found
No related merge requests found
Pipeline #
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -929,10 +929,20 @@ describe User, models: true do
end
 
context 'with a group route matching the given path' do
let!(:group) { create(:group, path: 'group_path') }
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)
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
expect(User.find_by_full_path('group_path')).to eq(nil)
end
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment