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