Commit 87f15e2a authored by Imre Farkas's avatar Imre Farkas

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

Replace owner with first_owner in service specs

See merge request gitlab-org/gitlab!78518
parents ff8e57d3 6a536713
...@@ -301,6 +301,10 @@ class Namespace < ApplicationRecord ...@@ -301,6 +301,10 @@ class Namespace < ApplicationRecord
user_namespace? user_namespace?
end end
def first_owner
owner
end
def find_fork_of(project) def find_fork_of(project)
return unless project.fork_network return unless project.fork_network
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Branches::DeleteMergedService do RSpec.describe Branches::DeleteMergedService do
include ProjectForksHelper include ProjectForksHelper
subject(:service) { described_class.new(project, project.owner) } subject(:service) { described_class.new(project, project.first_owner) }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Ci::AfterRequeueJobService do RSpec.describe Ci::AfterRequeueJobService do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let(:pipeline) { create(:ci_pipeline, project: project) } let(:pipeline) { create(:ci_pipeline, project: project) }
......
...@@ -604,7 +604,7 @@ RSpec.describe Ci::CreateDownstreamPipelineService, '#execute' do ...@@ -604,7 +604,7 @@ RSpec.describe Ci::CreateDownstreamPipelineService, '#execute' do
context 'when configured with bridge job rules' do context 'when configured with bridge job rules' do
before do before do
stub_ci_pipeline_yaml_file(config) stub_ci_pipeline_yaml_file(config)
downstream_project.add_maintainer(upstream_project.owner) downstream_project.add_maintainer(upstream_project.first_owner)
end end
let(:config) do let(:config) do
...@@ -622,13 +622,13 @@ RSpec.describe Ci::CreateDownstreamPipelineService, '#execute' do ...@@ -622,13 +622,13 @@ RSpec.describe Ci::CreateDownstreamPipelineService, '#execute' do
end end
let(:primary_pipeline) do let(:primary_pipeline) do
Ci::CreatePipelineService.new(upstream_project, upstream_project.owner, { ref: 'master' }) Ci::CreatePipelineService.new(upstream_project, upstream_project.first_owner, { ref: 'master' })
.execute(:push, save_on_errors: false) .execute(:push, save_on_errors: false)
.payload .payload
end end
let(:bridge) { primary_pipeline.processables.find_by(name: 'bridge-job') } let(:bridge) { primary_pipeline.processables.find_by(name: 'bridge-job') }
let(:service) { described_class.new(upstream_project, upstream_project.owner) } let(:service) { described_class.new(upstream_project, upstream_project.first_owner) }
context 'that include the bridge job' do context 'that include the bridge job' do
it 'creates the downstream pipeline' do it 'creates the downstream pipeline' do
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Ci::CreatePipelineService do RSpec.describe Ci::CreatePipelineService do
context 'cache' do context 'cache' do
let(:project) { create(:project, :custom_repo, files: files) } let(:project) { create(:project, :custom_repo, files: files) }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:ref) { 'refs/heads/master' } let(:ref) { 'refs/heads/master' }
let(:source) { :push } let(:source) { :push }
let(:service) { described_class.new(project, user, { ref: ref }) } let(:service) { described_class.new(project, user, { ref: ref }) }
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Ci::CreatePipelineService do RSpec.describe Ci::CreatePipelineService do
describe 'creation errors and warnings' do describe 'creation errors and warnings' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let(:ref) { 'refs/heads/master' } let(:ref) { 'refs/heads/master' }
let(:source) { :push } let(:source) { :push }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
RSpec.describe Ci::CreatePipelineService do RSpec.describe Ci::CreatePipelineService do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let(:ref) { 'refs/heads/master' } let(:ref) { 'refs/heads/master' }
let(:service) { described_class.new(project, user, { ref: ref }) } let(:service) { described_class.new(project, user, { ref: ref }) }
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Ci::CreatePipelineService do RSpec.describe Ci::CreatePipelineService do
describe '!reference tags' do describe '!reference tags' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let(:ref) { 'refs/heads/master' } let(:ref) { 'refs/heads/master' }
let(:source) { :push } let(:source) { :push }
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Ci::CreatePipelineService do RSpec.describe Ci::CreatePipelineService do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let(:ref) { 'refs/heads/master' } let(:ref) { 'refs/heads/master' }
let(:service) { described_class.new(project, user, { ref: ref }) } let(:service) { described_class.new(project, user, { ref: ref }) }
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Ci::CreatePipelineService do RSpec.describe Ci::CreatePipelineService do
context 'include:' do context 'include:' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let(:ref) { 'refs/heads/master' } let(:ref) { 'refs/heads/master' }
let(:variables_attributes) { [{ key: 'MYVAR', secret_value: 'hello' }] } let(:variables_attributes) { [{ key: 'MYVAR', secret_value: 'hello' }] }
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Ci::CreatePipelineService do RSpec.describe Ci::CreatePipelineService do
context 'pipeline logger' do context 'pipeline logger' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let(:ref) { 'refs/heads/master' } let(:ref) { 'refs/heads/master' }
let(:service) { described_class.new(project, user, { ref: ref }) } let(:service) { described_class.new(project, user, { ref: ref }) }
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Ci::CreatePipelineService do RSpec.describe Ci::CreatePipelineService do
context 'merge requests handling' do context 'merge requests handling' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let(:ref) { 'refs/heads/feature' } let(:ref) { 'refs/heads/feature' }
let(:source) { :push } let(:source) { :push }
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Ci::CreatePipelineService do RSpec.describe Ci::CreatePipelineService do
context 'needs' do context 'needs' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let(:ref) { 'refs/heads/master' } let(:ref) { 'refs/heads/master' }
let(:source) { :push } let(:source) { :push }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
RSpec.describe Ci::CreatePipelineService do RSpec.describe Ci::CreatePipelineService do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let(:service) { described_class.new(project, user, { ref: 'master' }) } let(:service) { described_class.new(project, user, { ref: 'master' }) }
let(:pipeline) { service.execute(:push).payload } let(:pipeline) { service.execute(:push).payload }
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Ci::CreatePipelineService do RSpec.describe Ci::CreatePipelineService do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let(:service) { described_class.new(project, user, { ref: 'refs/heads/master' }) } let(:service) { described_class.new(project, user, { ref: 'refs/heads/master' }) }
let(:content) do let(:content) do
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Ci::CreatePipelineService do RSpec.describe Ci::CreatePipelineService do
describe '.pre/.post stages' do describe '.pre/.post stages' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let(:source) { :push } let(:source) { :push }
let(:service) { described_class.new(project, user, { ref: ref }) } let(:service) { described_class.new(project, user, { ref: ref }) }
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
RSpec.describe Ci::CreatePipelineService do RSpec.describe Ci::CreatePipelineService do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:ref) { 'refs/heads/master' } let(:ref) { 'refs/heads/master' }
let(:source) { :push } let(:source) { :push }
let(:service) { described_class.new(project, user, { ref: ref }) } let(:service) { described_class.new(project, user, { ref: ref }) }
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Ci::CreatePipelineService do RSpec.describe Ci::CreatePipelineService do
describe 'tags:' do describe 'tags:' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let(:ref) { 'refs/heads/master' } let(:ref) { 'refs/heads/master' }
let(:service) { described_class.new(project, user, { ref: ref }) } let(:service) { described_class.new(project, user, { ref: ref }) }
......
...@@ -6,7 +6,7 @@ RSpec.describe Ci::CreatePipelineService do ...@@ -6,7 +6,7 @@ RSpec.describe Ci::CreatePipelineService do
include ProjectForksHelper include ProjectForksHelper
let_it_be_with_refind(:project) { create(:project, :repository) } let_it_be_with_refind(:project) { create(:project, :repository) }
let_it_be_with_reload(:user) { project.owner } let_it_be_with_reload(:user) { project.first_owner }
let(:ref_name) { 'refs/heads/master' } let(:ref_name) { 'refs/heads/master' }
......
...@@ -10,7 +10,7 @@ RSpec.describe ::Ci::DestroyPipelineService do ...@@ -10,7 +10,7 @@ RSpec.describe ::Ci::DestroyPipelineService do
subject { described_class.new(project, user).execute(pipeline) } subject { described_class.new(project, user).execute(pipeline) }
context 'user is owner' do context 'user is owner' do
let(:user) { project.owner } let(:user) { project.first_owner }
it 'destroys the pipeline' do it 'destroys the pipeline' do
subject subject
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Ci::PipelineProcessing::AtomicProcessingService do RSpec.describe Ci::PipelineProcessing::AtomicProcessingService do
describe 'Pipeline Processing Service Tests With Yaml' do describe 'Pipeline Processing Service Tests With Yaml' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
where(:test_file_path) do where(:test_file_path) do
Dir.glob(Rails.root.join('spec/services/ci/pipeline_processing/test_cases/*.yml')) Dir.glob(Rails.root.join('spec/services/ci/pipeline_processing/test_cases/*.yml'))
...@@ -65,7 +65,7 @@ RSpec.describe Ci::PipelineProcessing::AtomicProcessingService do ...@@ -65,7 +65,7 @@ RSpec.describe Ci::PipelineProcessing::AtomicProcessingService do
describe 'Pipeline Processing Service' do describe 'Pipeline Processing Service' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:pipeline) do let(:pipeline) do
create(:ci_empty_pipeline, ref: 'master', project: project) create(:ci_empty_pipeline, ref: 'master', project: project)
......
...@@ -7,7 +7,7 @@ RSpec.describe Clusters::Integrations::CreateService, '#execute' do ...@@ -7,7 +7,7 @@ RSpec.describe Clusters::Integrations::CreateService, '#execute' do
let_it_be_with_reload(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) } let_it_be_with_reload(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let(:service) do let(:service) do
described_class.new(container: project, cluster: cluster, current_user: project.owner, params: params) described_class.new(container: project, cluster: cluster, current_user: project.first_owner, params: params)
end end
shared_examples_for 'a cluster integration' do |application_type| shared_examples_for 'a cluster integration' do |application_type|
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Discussions::UpdateDiffPositionService do RSpec.describe Discussions::UpdateDiffPositionService do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:current_user) { project.owner } let(:current_user) { project.first_owner }
let(:create_commit) { project.commit("913c66a37b4a45b9769037c55c2d238bd0942d2e") } let(:create_commit) { project.commit("913c66a37b4a45b9769037c55c2d238bd0942d2e") }
let(:modify_commit) { project.commit("874797c3a73b60d2187ed6e2fcabd289ff75171e") } let(:modify_commit) { project.commit("874797c3a73b60d2187ed6e2fcabd289ff75171e") }
let(:edit_commit) { project.commit("570e7b2abdd848b95f2f578043fc23bd6f6fd24d") } let(:edit_commit) { project.commit("570e7b2abdd848b95f2f578043fc23bd6f6fd24d") }
......
...@@ -7,7 +7,7 @@ RSpec.describe FeatureFlags::HookService do ...@@ -7,7 +7,7 @@ RSpec.describe FeatureFlags::HookService do
let_it_be(:namespace) { create(:namespace) } let_it_be(:namespace) { create(:namespace) }
let_it_be(:project) { create(:project, :repository, namespace: namespace) } let_it_be(:project) { create(:project, :repository, namespace: namespace) }
let_it_be(:feature_flag) { create(:operations_feature_flag, project: project) } let_it_be(:feature_flag) { create(:operations_feature_flag, project: project) }
let_it_be(:user) { namespace.owner } let_it_be(:user) { namespace.first_owner }
let!(:hook) { create(:project_hook, project: project) } let!(:hook) { create(:project_hook, project: project) }
let(:hook_data) { double } let(:hook_data) { double }
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Git::ProcessRefChangesService do RSpec.describe Git::ProcessRefChangesService do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:params) { { changes: git_changes } } let(:params) { { changes: git_changes } }
subject { described_class.new(project, user, params) } subject { described_class.new(project, user, params) }
...@@ -34,7 +34,7 @@ RSpec.describe Git::ProcessRefChangesService do ...@@ -34,7 +34,7 @@ RSpec.describe Git::ProcessRefChangesService do
it "calls #{push_service_class}" do it "calls #{push_service_class}" do
expect(push_service_class) expect(push_service_class)
.to receive(:new) .to receive(:new)
.with(project, project.owner, hash_including(execute_project_hooks: true, create_push_event: true)) .with(project, project.first_owner, hash_including(execute_project_hooks: true, create_push_event: true))
.exactly(changes.count).times .exactly(changes.count).times
.and_return(service) .and_return(service)
...@@ -58,7 +58,7 @@ RSpec.describe Git::ProcessRefChangesService do ...@@ -58,7 +58,7 @@ RSpec.describe Git::ProcessRefChangesService do
it "calls #{push_service_class} with execute_project_hooks set to false" do it "calls #{push_service_class} with execute_project_hooks set to false" do
expect(push_service_class) expect(push_service_class)
.to receive(:new) .to receive(:new)
.with(project, project.owner, hash_including(execute_project_hooks: false)) .with(project, project.first_owner, hash_including(execute_project_hooks: false))
.exactly(changes.count).times .exactly(changes.count).times
.and_return(service) .and_return(service)
...@@ -86,7 +86,7 @@ RSpec.describe Git::ProcessRefChangesService do ...@@ -86,7 +86,7 @@ RSpec.describe Git::ProcessRefChangesService do
it "calls #{push_service_class} with create_push_event set to false" do it "calls #{push_service_class} with create_push_event set to false" do
expect(push_service_class) expect(push_service_class)
.to receive(:new) .to receive(:new)
.with(project, project.owner, hash_including(create_push_event: false)) .with(project, project.first_owner, hash_including(create_push_event: false))
.exactly(changes.count).times .exactly(changes.count).times
.and_return(service) .and_return(service)
...@@ -170,7 +170,7 @@ RSpec.describe Git::ProcessRefChangesService do ...@@ -170,7 +170,7 @@ RSpec.describe Git::ProcessRefChangesService do
allow(push_service_class) allow(push_service_class)
.to receive(:new) .to receive(:new)
.with(project, project.owner, hash_including(execute_project_hooks: true, create_push_event: true)) .with(project, project.first_owner, hash_including(execute_project_hooks: true, create_push_event: true))
.exactly(changes.count).times .exactly(changes.count).times
.and_return(service) .and_return(service)
end end
......
...@@ -9,7 +9,7 @@ RSpec.describe Integrations::Test::ProjectService do ...@@ -9,7 +9,7 @@ RSpec.describe Integrations::Test::ProjectService do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let(:integration) { create(:integrations_slack, project: project) } let(:integration) { create(:integrations_slack, project: project) }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:event) { nil } let(:event) { nil }
let(:sample_data) { { data: 'sample' } } let(:sample_data) { { data: 'sample' } }
let(:success_result) { { success: true, result: {} } } let(:success_result) { { success: true, result: {} } }
......
...@@ -424,7 +424,7 @@ RSpec.describe Members::DestroyService do ...@@ -424,7 +424,7 @@ RSpec.describe Members::DestroyService do
end end
context 'deletion of invitations created by deleted project member' do context 'deletion of invitations created by deleted project member' do
let(:user) { project.owner } let(:user) { project.first_owner }
let(:member_user) { create(:user) } let(:member_user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Members::InviteService, :aggregate_failures, :clean_gitlab_redis_shared_state, :sidekiq_inline do RSpec.describe Members::InviteService, :aggregate_failures, :clean_gitlab_redis_shared_state, :sidekiq_inline do
let_it_be(:project, reload: true) { create(:project) } let_it_be(:project, reload: true) { create(:project) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let_it_be(:project_user) { create(:user) } let_it_be(:project_user) { create(:user) }
let_it_be(:namespace) { project.namespace } let_it_be(:namespace) { project.namespace }
......
...@@ -17,7 +17,7 @@ RSpec.describe MergeRequests::BaseService do ...@@ -17,7 +17,7 @@ RSpec.describe MergeRequests::BaseService do
} }
end end
subject { MergeRequests::CreateService.new(project: project, current_user: project.owner, params: params) } subject { MergeRequests::CreateService.new(project: project, current_user: project.first_owner, params: params) }
describe '#execute_hooks' do describe '#execute_hooks' do
shared_examples 'enqueues Jira sync worker' do shared_examples 'enqueues Jira sync worker' do
......
...@@ -6,7 +6,7 @@ RSpec.describe MergeRequests::SquashService do ...@@ -6,7 +6,7 @@ RSpec.describe MergeRequests::SquashService do
include GitHelpers include GitHelpers
let(:service) { described_class.new(project: project, current_user: user, params: { merge_request: merge_request }) } let(:service) { described_class.new(project: project, current_user: user, params: { merge_request: merge_request }) }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:repository) { project.repository.raw } let(:repository) { project.repository.raw }
let(:log_error) { "Failed to squash merge request #{merge_request.to_reference(full: true)}:" } let(:log_error) { "Failed to squash merge request #{merge_request.to_reference(full: true)}:" }
......
...@@ -1132,7 +1132,7 @@ RSpec.describe MergeRequests::UpdateService, :mailer do ...@@ -1132,7 +1132,7 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
context 'updating `force_remove_source_branch`' do context 'updating `force_remove_source_branch`' do
let(:target_project) { create(:project, :repository, :public) } let(:target_project) { create(:project, :repository, :public) }
let(:source_project) { fork_project(target_project, nil, repository: true) } let(:source_project) { fork_project(target_project, nil, repository: true) }
let(:user) { target_project.owner } let(:user) { target_project.first_owner }
let(:merge_request) do let(:merge_request) do
create(:merge_request, create(:merge_request,
source_project: source_project, source_project: source_project,
......
...@@ -402,7 +402,7 @@ RSpec.describe Notes::CreateService do ...@@ -402,7 +402,7 @@ RSpec.describe Notes::CreateService do
let_it_be(:design) { create(:design, :with_file) } let_it_be(:design) { create(:design, :with_file) }
let_it_be(:project) { design.project } let_it_be(:project) { design.project }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let_it_be(:params) do let_it_be(:params) do
{ {
type: 'DiffNote', type: 'DiffNote',
......
...@@ -2885,7 +2885,7 @@ RSpec.describe NotificationService, :mailer do ...@@ -2885,7 +2885,7 @@ RSpec.describe NotificationService, :mailer do
let(:member) { create(:user) } let(:member) { create(:user) }
before do before do
project.add_developer(member, current_user: project.owner) project.add_developer(member, current_user: project.first_owner)
end end
it do it do
...@@ -3287,7 +3287,7 @@ RSpec.describe NotificationService, :mailer do ...@@ -3287,7 +3287,7 @@ RSpec.describe NotificationService, :mailer do
let_it_be(:domain, reload: true) { create(:pages_domain, project: project) } let_it_be(:domain, reload: true) { create(:pages_domain, project: project) }
let_it_be(:u_blocked) { create(:user, :blocked) } let_it_be(:u_blocked) { create(:user, :blocked) }
let_it_be(:u_silence) { create_user_with_notification(:disabled, 'silent', project) } let_it_be(:u_silence) { create_user_with_notification(:disabled, 'silent', project) }
let_it_be(:u_owner) { project.owner } let_it_be(:u_owner) { project.first_owner }
let_it_be(:u_maintainer1) { create(:user) } let_it_be(:u_maintainer1) { create(:user) }
let_it_be(:u_maintainer2) { create(:user) } let_it_be(:u_maintainer2) { create(:user) }
let_it_be(:u_developer) { create(:user) } let_it_be(:u_developer) { create(:user) }
...@@ -3395,7 +3395,7 @@ RSpec.describe NotificationService, :mailer do ...@@ -3395,7 +3395,7 @@ RSpec.describe NotificationService, :mailer do
let(:remote_mirror) { create(:remote_mirror, project: project) } let(:remote_mirror) { create(:remote_mirror, project: project) }
let(:u_blocked) { create(:user, :blocked) } let(:u_blocked) { create(:user, :blocked) }
let(:u_silence) { create_user_with_notification(:disabled, 'silent-maintainer', project) } let(:u_silence) { create_user_with_notification(:disabled, 'silent-maintainer', project) }
let(:u_owner) { project.owner } let(:u_owner) { project.first_owner }
let(:u_maintainer1) { create(:user) } let(:u_maintainer1) { create(:user) }
let(:u_maintainer2) { create(:user) } let(:u_maintainer2) { create(:user) }
let(:u_developer) { create(:user) } let(:u_developer) { create(:user) }
...@@ -3489,7 +3489,7 @@ RSpec.describe NotificationService, :mailer do ...@@ -3489,7 +3489,7 @@ RSpec.describe NotificationService, :mailer do
it 'sends the email to owners and masters' do it 'sends the email to owners and masters' do
expect(Notify).to receive(:prometheus_alert_fired_email).with(project, master, alert).and_call_original expect(Notify).to receive(:prometheus_alert_fired_email).with(project, master, alert).and_call_original
expect(Notify).to receive(:prometheus_alert_fired_email).with(project, project.owner, alert).and_call_original expect(Notify).to receive(:prometheus_alert_fired_email).with(project, project.first_owner, alert).and_call_original
expect(Notify).not_to receive(:prometheus_alert_fired_email).with(project, developer, alert) expect(Notify).not_to receive(:prometheus_alert_fired_email).with(project, developer, alert)
subject.prometheus_alerts_fired(project, [alert]) subject.prometheus_alerts_fired(project, [alert])
......
...@@ -119,7 +119,7 @@ RSpec.describe Projects::CreateService, '#execute' do ...@@ -119,7 +119,7 @@ RSpec.describe Projects::CreateService, '#execute' do
project = create_project(user, opts) project = create_project(user, opts)
expect(project).to be_valid expect(project).to be_valid
expect(project.owner).to eq(user) expect(project.first_owner).to eq(user)
expect(project.team.maintainers).to include(user) expect(project.team.maintainers).to include(user)
expect(project.namespace).to eq(user.namespace) expect(project.namespace).to eq(user.namespace)
expect(project.project_namespace).to be_in_sync_with_project(project) expect(project.project_namespace).to be_in_sync_with_project(project)
...@@ -154,6 +154,7 @@ RSpec.describe Projects::CreateService, '#execute' do ...@@ -154,6 +154,7 @@ RSpec.describe Projects::CreateService, '#execute' do
expect(project).to be_persisted expect(project).to be_persisted
expect(project.owner).to eq(user) expect(project.owner).to eq(user)
expect(project.first_owner).to eq(user)
expect(project.team.maintainers).to contain_exactly(user) expect(project.team.maintainers).to contain_exactly(user)
expect(project.namespace).to eq(user.namespace) expect(project.namespace).to eq(user.namespace)
expect(project.project_namespace).to be_in_sync_with_project(project) expect(project.project_namespace).to be_in_sync_with_project(project)
......
...@@ -64,7 +64,7 @@ RSpec.describe Projects::DestroyService, :aggregate_failures do ...@@ -64,7 +64,7 @@ RSpec.describe Projects::DestroyService, :aggregate_failures do
create(:ci_pipeline_artifact, pipeline: pipeline) create(:ci_pipeline_artifact, pipeline: pipeline)
create_list(:ci_build_trace_chunk, 3, build: builds[0]) create_list(:ci_build_trace_chunk, 3, build: builds[0])
expect { destroy_project(project, project.owner, {}) }.not_to exceed_query_limit(recorder) expect { destroy_project(project, project.first_owner, {}) }.not_to exceed_query_limit(recorder)
end end
it_behaves_like 'deleting the project' it_behaves_like 'deleting the project'
......
...@@ -61,7 +61,7 @@ RSpec.describe Projects::ForkService do ...@@ -61,7 +61,7 @@ RSpec.describe Projects::ForkService do
it { expect(to_project).to be_persisted } it { expect(to_project).to be_persisted }
it { expect(to_project.errors).to be_empty } it { expect(to_project.errors).to be_empty }
it { expect(to_project.owner).to eq(@to_user) } it { expect(to_project.first_owner).to eq(@to_user) }
it { expect(to_project.namespace).to eq(@to_user.namespace) } it { expect(to_project.namespace).to eq(@to_user.namespace) }
it { expect(to_project.star_count).to be_zero } it { expect(to_project.star_count).to be_zero }
it { expect(to_project.description).to eq(@from_project.description) } it { expect(to_project.description).to eq(@from_project.description) }
...@@ -274,7 +274,7 @@ RSpec.describe Projects::ForkService do ...@@ -274,7 +274,7 @@ RSpec.describe Projects::ForkService do
expect(to_project).to be_persisted expect(to_project).to be_persisted
expect(to_project.errors).to be_empty expect(to_project.errors).to be_empty
expect(to_project.owner).to eq(@group) expect(to_project.first_owner).to eq(@group_owner)
expect(to_project.namespace).to eq(@group) expect(to_project.namespace).to eq(@group)
expect(to_project.name).to eq(@project.name) expect(to_project.name).to eq(@project.name)
expect(to_project.path).to eq(@project.path) expect(to_project.path).to eq(@project.path)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Projects::RepositoryLanguagesService do RSpec.describe Projects::RepositoryLanguagesService do
let(:service) { described_class.new(project, project.owner) } let(:service) { described_class.new(project, project.first_owner) }
context 'when detected_repository_languages flag is set' do context 'when detected_repository_languages flag is set' do
let(:project) { create(:project) } let(:project) { create(:project) }
......
...@@ -15,7 +15,7 @@ RSpec.describe Projects::UpdateRemoteMirrorService do ...@@ -15,7 +15,7 @@ RSpec.describe Projects::UpdateRemoteMirrorService do
subject(:execute!) { service.execute(remote_mirror, retries) } subject(:execute!) { service.execute(remote_mirror, retries) }
before do before do
project.repository.add_branch(project.owner, 'existing-branch', 'master') project.repository.add_branch(project.first_owner, 'existing-branch', 'master')
allow(remote_mirror) allow(remote_mirror)
.to receive(:update_repository) .to receive(:update_repository)
......
...@@ -149,7 +149,7 @@ RSpec.describe Projects::UpdateService do ...@@ -149,7 +149,7 @@ RSpec.describe Projects::UpdateService do
describe 'when updating project that has forks' do describe 'when updating project that has forks' do
let(:project) { create(:project, :internal) } let(:project) { create(:project, :internal) }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:forked_project) { fork_project(project) } let(:forked_project) { fork_project(project) }
context 'and unlink forks feature flag is off' do context 'and unlink forks feature flag is off' do
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe ProtectedBranches::CreateService do RSpec.describe ProtectedBranches::CreateService do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:params) do let(:params) do
{ {
name: name, name: name,
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe ProtectedBranches::DestroyService do RSpec.describe ProtectedBranches::DestroyService do
let(:protected_branch) { create(:protected_branch) } let(:protected_branch) { create(:protected_branch) }
let(:project) { protected_branch.project } let(:project) { protected_branch.project }
let(:user) { project.owner } let(:user) { project.first_owner }
describe '#execute' do describe '#execute' do
subject(:service) { described_class.new(project, user) } subject(:service) { described_class.new(project, user) }
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe ProtectedBranches::UpdateService do RSpec.describe ProtectedBranches::UpdateService do
let(:protected_branch) { create(:protected_branch) } let(:protected_branch) { create(:protected_branch) }
let(:project) { protected_branch.project } let(:project) { protected_branch.project }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:params) { { name: new_name } } let(:params) { { name: new_name } }
describe '#execute' do describe '#execute' do
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe ProtectedTags::CreateService do RSpec.describe ProtectedTags::CreateService do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:params) do let(:params) do
{ {
name: name, name: name,
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe ProtectedTags::DestroyService do RSpec.describe ProtectedTags::DestroyService do
let(:protected_tag) { create(:protected_tag) } let(:protected_tag) { create(:protected_tag) }
let(:project) { protected_tag.project } let(:project) { protected_tag.project }
let(:user) { project.owner } let(:user) { project.first_owner }
describe '#execute' do describe '#execute' do
subject(:service) { described_class.new(project, user) } subject(:service) { described_class.new(project, user) }
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe ProtectedTags::UpdateService do RSpec.describe ProtectedTags::UpdateService do
let(:protected_tag) { create(:protected_tag) } let(:protected_tag) { create(:protected_tag) }
let(:project) { protected_tag.project } let(:project) { protected_tag.project }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:params) { { name: new_name } } let(:params) { { name: new_name } }
describe '#execute' do describe '#execute' do
......
...@@ -9,7 +9,7 @@ RSpec.describe TestHooks::SystemService do ...@@ -9,7 +9,7 @@ RSpec.describe TestHooks::SystemService do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let(:hook) { create(:system_hook) } let(:hook) { create(:system_hook) }
let(:service) { described_class.new(hook, project.owner, trigger) } let(:service) { described_class.new(hook, project.first_owner, trigger) }
let(:success_result) { { status: :success, http_status: 200, message: 'ok' } } let(:success_result) { { status: :success, http_status: 200, message: 'ok' } }
before do before do
......
...@@ -9,7 +9,7 @@ RSpec.describe Users::RefreshAuthorizedProjectsService do ...@@ -9,7 +9,7 @@ RSpec.describe Users::RefreshAuthorizedProjectsService do
# triggered twice. # triggered twice.
let!(:project) { create(:project) } let!(:project) { create(:project) }
let(:user) { project.namespace.owner } let(:user) { project.namespace.first_owner }
let(:service) { described_class.new(user) } let(:service) { described_class.new(user) }
describe '#execute', :clean_gitlab_redis_shared_state do describe '#execute', :clean_gitlab_redis_shared_state 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