Commit 97ce01c9 authored by Pavel Shutsin's avatar Pavel Shutsin

Merge branch '350603-cablett-project-owner-specs-9' into 'master'

Replace owner with first_owner in mailer/model specs

See merge request gitlab-org/gitlab!78982
parents df5f07ac 3f16c59c
...@@ -714,7 +714,7 @@ RSpec.describe Notify do ...@@ -714,7 +714,7 @@ RSpec.describe Notify do
describe 'project access requested' do describe 'project access requested' do
let(:project) do let(:project) do
create(:project, :public) do |project| create(:project, :public) do |project|
project.add_maintainer(project.owner) project.add_maintainer(project.first_owner)
end end
end end
......
...@@ -394,7 +394,7 @@ RSpec.describe Ability do ...@@ -394,7 +394,7 @@ RSpec.describe Ability do
describe '.project_disabled_features_rules' do describe '.project_disabled_features_rules' do
let(:project) { create(:project, :wiki_disabled) } let(:project) { create(:project, :wiki_disabled) }
subject { described_class.policy_for(project.owner, project) } subject { described_class.policy_for(project.first_owner, project) }
context 'wiki named abilities' do context 'wiki named abilities' do
it 'disables wiki abilities if the project has no wiki' do it 'disables wiki abilities if the project has no wiki' do
......
...@@ -851,7 +851,7 @@ RSpec.describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state, :clean_git ...@@ -851,7 +851,7 @@ RSpec.describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state, :clean_git
context 'when project is destroyed' do context 'when project is destroyed' do
let(:subject) do let(:subject) do
Projects::DestroyService.new(project, project.owner).execute Projects::DestroyService.new(project, project.first_owner).execute
end end
it_behaves_like 'deletes all build_trace_chunk and data in redis' it_behaves_like 'deletes all build_trace_chunk and data in redis'
......
...@@ -3427,7 +3427,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do ...@@ -3427,7 +3427,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
create(:ci_pipeline, create(:ci_pipeline,
project: project, project: project,
sha: project.commit('master').sha, sha: project.commit('master').sha,
user: project.owner) user: project.first_owner)
end end
before do before do
...@@ -4502,7 +4502,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do ...@@ -4502,7 +4502,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe '#reset_source_bridge!' do describe '#reset_source_bridge!' do
let(:pipeline) { create(:ci_pipeline, :created, project: project) } let(:pipeline) { create(:ci_pipeline, :created, project: project) }
subject(:reset_bridge) { pipeline.reset_source_bridge!(project.owner) } subject(:reset_bridge) { pipeline.reset_source_bridge!(project.first_owner) }
context 'when the pipeline is a child pipeline and the bridge is depended' do context 'when the pipeline is a child pipeline and the bridge is depended' do
let!(:parent_pipeline) { create(:ci_pipeline) } let!(:parent_pipeline) { create(:ci_pipeline) }
......
...@@ -59,7 +59,7 @@ RSpec.describe Ci::Trigger do ...@@ -59,7 +59,7 @@ RSpec.describe Ci::Trigger do
end end
it_behaves_like 'includes Limitable concern' do it_behaves_like 'includes Limitable concern' do
subject { build(:ci_trigger, owner: project.owner, project: project) } subject { build(:ci_trigger, owner: project.first_owner, project: project) }
end end
context 'loose foreign key on ci_triggers.owner_id' do context 'loose foreign key on ci_triggers.owner_id' do
......
...@@ -486,7 +486,7 @@ eos ...@@ -486,7 +486,7 @@ eos
it 'uses the CachedMarkdownField cache instead of the Mentionable cache', :use_clean_rails_redis_caching do it 'uses the CachedMarkdownField cache instead of the Mentionable cache', :use_clean_rails_redis_caching do
expect(commit.title_html).not_to be_present expect(commit.title_html).not_to be_present
commit.all_references(project.owner).all commit.all_references(project.first_owner).all
expect(commit.title_html).to be_present expect(commit.title_html).to be_present
expect(Rails.cache.read("banzai/commit:#{commit.id}/safe_message/single_line")).to be_nil expect(Rails.cache.read("banzai/commit:#{commit.id}/safe_message/single_line")).to be_nil
......
...@@ -161,7 +161,7 @@ RSpec.describe EnvironmentStatus do ...@@ -161,7 +161,7 @@ RSpec.describe EnvironmentStatus do
let!(:build) { create(:ci_build, :with_deployment, :deploy_to_production, pipeline: pipeline) } let!(:build) { create(:ci_build, :with_deployment, :deploy_to_production, pipeline: pipeline) }
let(:environment) { build.deployment.environment } let(:environment) { build.deployment.environment }
let(:user) { project.owner } let(:user) { project.first_owner }
context 'when environment is created on a forked project', :sidekiq_inline do context 'when environment is created on a forked project', :sidekiq_inline do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
......
...@@ -25,7 +25,7 @@ RSpec.describe Event do ...@@ -25,7 +25,7 @@ RSpec.describe Event do
expect(instance).to receive(:reset_project_activity) expect(instance).to receive(:reset_project_activity)
end end
create_push_event(project, project.owner) create_push_event(project, project.first_owner)
end end
end end
...@@ -34,7 +34,7 @@ RSpec.describe Event do ...@@ -34,7 +34,7 @@ RSpec.describe Event do
it 'updates the project last_repository_updated_at and updated_at' do it 'updates the project last_repository_updated_at and updated_at' do
project.touch(:last_repository_updated_at, time: 1.year.ago) # rubocop: disable Rails/SkipsModelValidations project.touch(:last_repository_updated_at, time: 1.year.ago) # rubocop: disable Rails/SkipsModelValidations
event = create_push_event(project, project.owner) event = create_push_event(project, project.first_owner)
project.reload project.reload
...@@ -47,7 +47,7 @@ RSpec.describe Event do ...@@ -47,7 +47,7 @@ RSpec.describe Event do
it 'does not update the project last_repository_updated_at' do it 'does not update the project last_repository_updated_at' do
project.update!(last_repository_updated_at: 1.year.ago) project.update!(last_repository_updated_at: 1.year.ago)
create(:closed_issue_event, project: project, author: project.owner) create(:closed_issue_event, project: project, author: project.first_owner)
project.reload project.reload
...@@ -63,14 +63,14 @@ RSpec.describe Event do ...@@ -63,14 +63,14 @@ RSpec.describe Event do
project.reload # a reload removes fractions of seconds project.reload # a reload removes fractions of seconds
expect do expect do
create_push_event(project, project.owner) create_push_event(project, project.first_owner)
project.reload project.reload
end.not_to change { project.last_repository_updated_at } end.not_to change { project.last_repository_updated_at }
end end
end end
describe 'after_create UserInteractedProject.track' do describe 'after_create UserInteractedProject.track' do
let(:event) { build(:push_event, project: project, author: project.owner) } let(:event) { build(:push_event, project: project, author: project.first_owner) }
it 'passes event to UserInteractedProject.track' do it 'passes event to UserInteractedProject.track' do
expect(UserInteractedProject).to receive(:track).with(event) expect(UserInteractedProject).to receive(:track).with(event)
...@@ -157,7 +157,7 @@ RSpec.describe Event do ...@@ -157,7 +157,7 @@ RSpec.describe Event do
describe "Push event" do describe "Push event" do
let(:project) { create(:project, :private) } let(:project) { create(:project, :private) }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:event) { create_push_event(project, user) } let(:event) { create_push_event(project, user) }
it do it do
...@@ -173,7 +173,7 @@ RSpec.describe Event do ...@@ -173,7 +173,7 @@ RSpec.describe Event do
describe '#target_title' do describe '#target_title' do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let(:author) { project.owner } let(:author) { project.first_owner }
let(:target) { nil } let(:target) { nil }
let(:event) do let(:event) do
...@@ -746,7 +746,7 @@ RSpec.describe Event do ...@@ -746,7 +746,7 @@ RSpec.describe Event do
target = kind == :project ? nil : build(kind, **extra_data) target = kind == :project ? nil : build(kind, **extra_data)
[kind, build(:event, :created, author: project.owner, project: project, target: target)] [kind, build(:event, :created, author: project.first_owner, project: project, target: target)]
end end
end end
...@@ -830,7 +830,7 @@ RSpec.describe Event do ...@@ -830,7 +830,7 @@ RSpec.describe Event do
expect(project).not_to receive(:update_column) expect(project).not_to receive(:update_column)
.with(:last_activity_at, a_kind_of(Time)) .with(:last_activity_at, a_kind_of(Time))
create_push_event(project, project.owner) create_push_event(project, project.first_owner)
end end
end end
...@@ -838,7 +838,7 @@ RSpec.describe Event do ...@@ -838,7 +838,7 @@ RSpec.describe Event do
it 'updates the project' do it 'updates the project' do
project.touch(:last_activity_at, time: 1.year.ago) # rubocop: disable Rails/SkipsModelValidations project.touch(:last_activity_at, time: 1.year.ago) # rubocop: disable Rails/SkipsModelValidations
event = create_push_event(project, project.owner) event = create_push_event(project, project.first_owner)
project.reload project.reload
......
...@@ -1249,7 +1249,7 @@ RSpec.describe Group do ...@@ -1249,7 +1249,7 @@ RSpec.describe Group do
let(:common_id) { [Project.maximum(:id).to_i, Namespace.maximum(:id).to_i].max + 999 } let(:common_id) { [Project.maximum(:id).to_i, Namespace.maximum(:id).to_i].max + 999 }
let!(:group) { create(:group, id: common_id) } let!(:group) { create(:group, id: common_id) }
let!(:unrelated_project) { create(:project, id: common_id) } let!(:unrelated_project) { create(:project, id: common_id) }
let(:user) { unrelated_project.owner } let(:user) { unrelated_project.first_owner }
it 'returns correct access level' do it 'returns correct access level' do
expect(shared_group_parent.max_member_access_for_user(user)).to eq(Gitlab::Access::NO_ACCESS) expect(shared_group_parent.max_member_access_for_user(user)).to eq(Gitlab::Access::NO_ACCESS)
......
...@@ -50,7 +50,9 @@ RSpec.describe IssueCollection do ...@@ -50,7 +50,9 @@ RSpec.describe IssueCollection do
end end
end end
context 'using a user that is the owner of a project' do # TODO update when we have multiple owners of a project
# https://gitlab.com/gitlab-org/gitlab/-/issues/350605
context 'using a user that is an owner of a project' do
it 'returns the issues of the project' do it 'returns the issues of the project' do
expect(collection.updatable_by_user(project.namespace.owner)) expect(collection.updatable_by_user(project.namespace.owner))
.to eq([issue1, issue2]) .to eq([issue1, issue2])
......
...@@ -887,6 +887,8 @@ RSpec.describe Issue do ...@@ -887,6 +887,8 @@ RSpec.describe Issue do
end end
end end
# TODO update when we have multiple owners of a project
# https://gitlab.com/gitlab-org/gitlab/-/issues/350605
context 'with an owner' do context 'with an owner' do
before do before do
project.add_maintainer(user) project.add_maintainer(user)
......
...@@ -617,7 +617,7 @@ RSpec.describe Note do ...@@ -617,7 +617,7 @@ RSpec.describe Note do
let(:note) do let(:note) do
create :note, create :note,
noteable: ext_issue, project: ext_proj, noteable: ext_issue, project: ext_proj,
note: "mentioned in #{ext_proj.owner.to_reference}", note: "mentioned in #{ext_proj.first_owner.to_reference}",
system: true system: true
end end
......
...@@ -871,6 +871,8 @@ RSpec.describe Project, factory_default: :keep do ...@@ -871,6 +871,8 @@ RSpec.describe Project, factory_default: :keep do
end end
describe 'reference methods' do describe 'reference methods' do
# TODO update when we have multiple owners of a project
# https://gitlab.com/gitlab-org/gitlab/-/issues/350605
let_it_be(:owner) { create(:user, name: 'Gitlab') } let_it_be(:owner) { create(:user, name: 'Gitlab') }
let_it_be(:namespace) { create(:namespace, name: 'Sample namespace', path: 'sample-namespace', owner: owner) } let_it_be(:namespace) { create(:namespace, name: 'Sample namespace', path: 'sample-namespace', owner: owner) }
let_it_be(:project) { create(:project, name: 'Sample project', path: 'sample-project', namespace: namespace) } let_it_be(:project) { create(:project, name: 'Sample project', path: 'sample-project', namespace: namespace) }
...@@ -2874,7 +2876,7 @@ RSpec.describe Project, factory_default: :keep do ...@@ -2874,7 +2876,7 @@ RSpec.describe Project, factory_default: :keep do
end end
before do before do
project.repository.rm_branch(project.owner, branch.name) project.repository.rm_branch(project.first_owner, branch.name)
end end
subject { project.latest_pipeline(branch.name) } subject { project.latest_pipeline(branch.name) }
......
...@@ -80,7 +80,7 @@ RSpec.describe ProjectTeam do ...@@ -80,7 +80,7 @@ RSpec.describe ProjectTeam do
describe 'owner methods' do describe 'owner methods' do
context 'personal project' do context 'personal project' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:owner) { project.owner } let(:owner) { project.first_owner }
specify { expect(project.team.owners).to contain_exactly(owner) } specify { expect(project.team.owners).to contain_exactly(owner) }
specify { expect(project.team.owner?(owner)).to be_truthy } specify { expect(project.team.owner?(owner)).to be_truthy }
...@@ -108,10 +108,12 @@ RSpec.describe ProjectTeam do ...@@ -108,10 +108,12 @@ RSpec.describe ProjectTeam do
let(:project) { create(:project) } let(:project) { create(:project) }
it 'returns project members' do it 'returns project members' do
# TODO this can be updated when we have multiple project owners
# See https://gitlab.com/gitlab-org/gitlab/-/issues/350605
user = create(:user) user = create(:user)
project.add_guest(user) project.add_guest(user)
expect(project.team.members).to contain_exactly(user, project.owner) expect(project.team.members).to contain_exactly(user, project.first_owner)
end end
it 'returns project members of a specified level' do it 'returns project members of a specified level' do
...@@ -129,7 +131,7 @@ RSpec.describe ProjectTeam do ...@@ -129,7 +131,7 @@ RSpec.describe ProjectTeam do
group_access: Gitlab::Access::GUEST) group_access: Gitlab::Access::GUEST)
expect(project.team.members) expect(project.team.members)
.to contain_exactly(group_member.user, project.owner) .to contain_exactly(group_member.user, project.first_owner)
end end
it 'returns invited members of a group of a specified level' do it 'returns invited members of a group of a specified level' 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