Commit ddf15292 authored by Sean Arnold's avatar Sean Arnold

Merge branch '241503-cablett-default-owner-first-owner' into 'master'

Rename default_owner to first_owner

See merge request gitlab-org/gitlab!78423
parents 21aadb30 8b231b04
......@@ -17,7 +17,7 @@ module HasWiki
def wiki
strong_memoize(:wiki) do
Wiki.for_container(self, self.default_owner)
Wiki.for_container(self, self.first_owner)
end
end
......
......@@ -725,8 +725,8 @@ class Group < Namespace
end
end
def default_owner
owners.first || parent&.default_owner || owner
def first_owner
owners.first || parent&.first_owner || owner
end
def default_branch_name
......
......@@ -1514,11 +1514,11 @@ class Project < ApplicationRecord
group || namespace.try(:owner)
end
def default_owner
def first_owner
obj = owner
if obj.respond_to?(:default_owner)
obj.default_owner
if obj.respond_to?(:first_owner)
obj.first_owner
else
obj
end
......
......@@ -16,7 +16,7 @@ module DesignManagement
@temporary_branch = "CopyDesignCollectionService_#{SecureRandom.hex}"
# The user who triggered the copy may not have permissions to push
# to the design repository.
@git_user = @target_project.default_owner
@git_user = @target_project.first_owner
@designs = DesignManagement::Design.unscoped.where(issue: issue).order(:id).load
@versions = DesignManagement::Version.unscoped.where(issue: issue).order(:id).includes(:designs).load
......
......@@ -7,7 +7,7 @@ RSpec.describe Git::WikiPushService do
let_it_be(:key_id) { create(:key, user: current_user).shell_id }
let_it_be(:wiki) { create(:project_wiki) }
let_it_be(:current_user) { wiki.container.default_owner }
let_it_be(:current_user) { wiki.container.first_owner }
let_it_be(:repository) { wiki.repository }
let(:post_received) { ::Gitlab::GitPostReceive.new(wiki.container, key_id, changes, {}) }
......
......@@ -4,7 +4,7 @@ FactoryBot.define do
factory :wiki do
transient do
container { association(:project) }
user { container.default_owner || association(:user) }
user { container.first_owner || association(:user) }
end
initialize_with { Wiki.for_container(container, user) }
......
......@@ -2539,7 +2539,7 @@ RSpec.describe Group do
end
end
describe '#default_owner' do
describe '#first_owner' do
let(:group) { build(:group) }
context 'the group has owners' do
......@@ -2549,7 +2549,7 @@ RSpec.describe Group do
end
it 'is the first owner' do
expect(group.default_owner)
expect(group.first_owner)
.to eq(group.owners.first)
.and be_a(User)
end
......@@ -2564,8 +2564,8 @@ RSpec.describe Group do
end
it 'is the first owner of the parent' do
expect(group.default_owner)
.to eq(parent.default_owner)
expect(group.first_owner)
.to eq(parent.first_owner)
.and be_a(User)
end
end
......@@ -2576,7 +2576,7 @@ RSpec.describe Group do
end
it 'is the group.owner' do
expect(group.default_owner)
expect(group.first_owner)
.to eq(group.owner)
.and be_a(User)
end
......
......@@ -1299,7 +1299,7 @@ RSpec.describe Project, factory_default: :keep do
end
end
describe '#default_owner' do
describe '#first_owner' do
let_it_be(:owner) { create(:user) }
let_it_be(:namespace) { create(:namespace, owner: owner) }
......@@ -1307,7 +1307,7 @@ RSpec.describe Project, factory_default: :keep do
let(:project) { build(:project, namespace: namespace) }
it 'is the namespace owner' do
expect(project.default_owner).to eq(owner)
expect(project.first_owner).to eq(owner)
end
end
......@@ -1316,9 +1316,9 @@ RSpec.describe Project, factory_default: :keep do
let(:project) { build(:project, group: group, namespace: namespace) }
it 'is the group owner' do
allow(group).to receive(:default_owner).and_return(Object.new)
allow(group).to receive(:first_owner).and_return(Object.new)
expect(project.default_owner).to eq(group.default_owner)
expect(project.first_owner).to eq(group.first_owner)
end
end
end
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
RSpec.describe 'shared/wikis/_sidebar.html.haml' do
let_it_be(:project) { create(:project) }
let_it_be(:wiki) { Wiki.for_container(project, project.default_owner) }
let_it_be(:wiki) { Wiki.for_container(project, project.first_owner) }
before do
assign(:wiki, wiki)
......
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