Commit ef688d84 authored by charlie ablett's avatar charlie ablett

Replace owner with first_owner in various specs

parent 99be341f
...@@ -11,7 +11,7 @@ RSpec.describe BuildDetailsEntity do ...@@ -11,7 +11,7 @@ RSpec.describe BuildDetailsEntity do
describe '#as_json' do describe '#as_json' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:pipeline) { create(:ci_pipeline, project: project) } let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, :failed, pipeline: pipeline) } let(:build) { create(:ci_build, :failed, pipeline: pipeline) }
let(:request) { double('request', project: project) } let(:request) { double('request', project: project) }
......
...@@ -7,7 +7,7 @@ RSpec.describe Ci::Lint::ResultSerializer, :aggregate_failures do ...@@ -7,7 +7,7 @@ RSpec.describe Ci::Lint::ResultSerializer, :aggregate_failures do
let(:result) do let(:result) do
Gitlab::Ci::Lint Gitlab::Ci::Lint
.new(project: project, current_user: project.owner) .new(project: project, current_user: project.first_owner)
.validate(yaml_content, dry_run: false) .validate(yaml_content, dry_run: false)
end end
...@@ -64,7 +64,7 @@ RSpec.describe Ci::Lint::ResultSerializer, :aggregate_failures do ...@@ -64,7 +64,7 @@ RSpec.describe Ci::Lint::ResultSerializer, :aggregate_failures do
context 'when dry run is enabled' do context 'when dry run is enabled' do
let(:result) do let(:result) do
Gitlab::Ci::Lint Gitlab::Ci::Lint
.new(project: project, current_user: project.owner) .new(project: project, current_user: project.first_owner)
.validate(yaml_content, dry_run: true) .validate(yaml_content, dry_run: true)
end end
......
...@@ -142,7 +142,7 @@ RSpec.describe DiffFileBaseEntity do ...@@ -142,7 +142,7 @@ RSpec.describe DiffFileBaseEntity do
end end
context 'when source_project and target_project are different' do context 'when source_project and target_project are different' do
let(:target_project) { fork_project(source_project, source_project.owner, repository: true) } let(:target_project) { fork_project(source_project, source_project.first_owner, repository: true) }
it 'returns the merge_request ide route with the target_project as param' do it 'returns the merge_request ide route with the target_project as param' do
expect(entity[:ide_edit_path]).to eq("#{expected_merge_request_path}?target_project=#{ERB::Util.url_encode(target_project.full_path)}") expect(entity[:ide_edit_path]).to eq("#{expected_merge_request_path}?target_project=#{ERB::Util.url_encode(target_project.full_path)}")
......
...@@ -7,7 +7,7 @@ RSpec.describe RunnerEntity do ...@@ -7,7 +7,7 @@ RSpec.describe RunnerEntity do
let(:runner) { create(:ci_runner, :project, projects: [project]) } let(:runner) { create(:ci_runner, :project, projects: [project]) }
let(:entity) { described_class.new(runner, request: request, current_user: user) } let(:entity) { described_class.new(runner, request: request, current_user: user) }
let(:request) { double('request') } let(:request) { double('request') }
let(:user) { project.owner } let(:user) { project.first_owner }
before do before do
allow(request).to receive(:current_user).and_return(user) allow(request).to receive(:current_user).and_return(user)
......
...@@ -31,7 +31,7 @@ RSpec.describe TriggerVariableEntity do ...@@ -31,7 +31,7 @@ RSpec.describe TriggerVariableEntity do
end end
context 'when user is owner' do context 'when user is owner' do
let(:user) { project.owner } let(:user) { project.first_owner }
it 'exposes the variable value' do it 'exposes the variable value' do
expect(subject).to include(:value) expect(subject).to include(:value)
......
...@@ -129,7 +129,7 @@ eos ...@@ -129,7 +129,7 @@ eos
commit_message: 'Add new content') commit_message: 'Add new content')
Files::CreateService.new( Files::CreateService.new(
project, project,
project.owner, project.first_owner,
commit_message: commit_message, commit_message: commit_message,
start_branch: start_branch, start_branch: start_branch,
branch_name: branch_name, branch_name: branch_name,
......
...@@ -11,7 +11,7 @@ RSpec.shared_context 'package details setup' do ...@@ -11,7 +11,7 @@ RSpec.shared_context 'package details setup' do
let(:package_files) { all_graphql_fields_for('PackageFile') } let(:package_files) { all_graphql_fields_for('PackageFile') }
let(:dependency_links) { all_graphql_fields_for('PackageDependencyLink') } let(:dependency_links) { all_graphql_fields_for('PackageDependencyLink') }
let(:pipelines) { all_graphql_fields_for('Pipeline', max_depth: 1) } let(:pipelines) { all_graphql_fields_for('Pipeline', max_depth: 1) }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:package_details) { graphql_data_at(:package) } let(:package_details) { graphql_data_at(:package) }
let(:metadata_response) { graphql_data_at(:package, :metadata) } let(:metadata_response) { graphql_data_at(:package, :metadata) }
let(:first_file) { package.package_files.find { |f| global_id_of(f) == first_file_response['id'] } } let(:first_file) { package.package_files.find { |f| global_id_of(f) == first_file_response['id'] } }
......
...@@ -62,7 +62,7 @@ RSpec.shared_examples 'a creatable merge request' do ...@@ -62,7 +62,7 @@ RSpec.shared_examples 'a creatable merge request' do
end end
it 'updates the branches when selecting a new target project', :js do it 'updates the branches when selecting a new target project', :js do
target_project_member = target_project.owner target_project_member = target_project.first_owner
::Branches::CreateService.new(target_project, target_project_member) ::Branches::CreateService.new(target_project, target_project_member)
.execute('a-brand-new-branch-to-test', 'master') .execute('a-brand-new-branch-to-test', 'master')
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.shared_examples 'ZenTao menu with CE version' do RSpec.shared_examples 'ZenTao menu with CE version' do
let(:project) { create(:project, has_external_issue_tracker: true) } let(:project) { create(:project, has_external_issue_tracker: true) }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:context) { Sidebars::Projects::Context.new(current_user: user, container: project) } let(:context) { Sidebars::Projects::Context.new(current_user: user, container: project) }
let(:zentao_integration) { create(:zentao_integration, project: project) } let(:zentao_integration) { create(:zentao_integration, project: project) }
......
...@@ -115,14 +115,14 @@ RSpec.shared_examples 'UpdateProjectStatistics' do |with_counter_attribute| ...@@ -115,14 +115,14 @@ RSpec.shared_examples 'UpdateProjectStatistics' do |with_counter_attribute|
expect(ProjectStatistics) expect(ProjectStatistics)
.not_to receive(:increment_statistic) .not_to receive(:increment_statistic)
expect(Projects::DestroyService.new(project, project.owner).execute).to eq(true) expect(Projects::DestroyService.new(project, project.first_owner).execute).to eq(true)
end end
it 'does not schedule a namespace statistics worker' do it 'does not schedule a namespace statistics worker' do
expect(Namespaces::ScheduleAggregationWorker) expect(Namespaces::ScheduleAggregationWorker)
.not_to receive(:perform_async) .not_to receive(:perform_async)
expect(Projects::DestroyService.new(project, project.owner).execute).to eq(true) expect(Projects::DestroyService.new(project, project.first_owner).execute).to eq(true)
end end
end end
end end
......
...@@ -190,7 +190,7 @@ RSpec.shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -190,7 +190,7 @@ RSpec.shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
if parent_type == 'projects' if parent_type == 'projects'
context 'by a project owner' do context 'by a project owner' do
let(:user) { project.owner } let(:user) { project.first_owner }
it 'sets the creation time on the new note' do it 'sets the creation time on the new note' do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: params post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: params
......
...@@ -344,9 +344,9 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do ...@@ -344,9 +344,9 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do
shared_examples 'includes repositories in all repository storages' do shared_examples 'includes repositories in all repository storages' do
specify :aggregate_failures do specify :aggregate_failures do
project_a = create(:project, :repository) project_a = create(:project, :repository)
project_snippet_a = create(:project_snippet, :repository, project: project_a, author: project_a.owner) project_snippet_a = create(:project_snippet, :repository, project: project_a, author: project_a.first_owner)
project_b = create(:project, :repository, repository_storage: second_storage_name) project_b = create(:project, :repository, repository_storage: second_storage_name)
project_snippet_b = create(:project_snippet, :repository, project: project_b, author: project_b.owner) project_snippet_b = create(:project_snippet, :repository, project: project_b, author: project_b.first_owner)
project_snippet_b.snippet_repository.update!(shard: project_b.project_repository.shard) project_snippet_b.snippet_repository.update!(shard: project_b.project_repository.shard)
create(:wiki_page, container: project_a) create(:wiki_page, container: project_a)
create(:design, :with_file, issue: create(:issue, project: project_a)) create(:design, :with_file, issue: create(:issue, project: project_a))
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe 'layouts/nav/sidebar/_project' do RSpec.describe 'layouts/nav/sidebar/_project' do
let_it_be_with_reload(:project) { create(:project, :repository) } let_it_be_with_reload(:project) { create(:project, :repository) }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:current_ref) { 'master' } let(:current_ref) { 'master' }
before do before do
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Ci::ExternalPullRequests::CreatePipelineWorker do RSpec.describe Ci::ExternalPullRequests::CreatePipelineWorker do
let_it_be(:project) { create(:project, :auto_devops, :repository) } let_it_be(:project) { create(:project, :auto_devops, :repository) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
let_it_be(:external_pull_request) do let_it_be(:external_pull_request) do
branch = project.repository.branches.last branch = project.repository.branches.last
create(:external_pull_request, project: project, source_branch: branch.name, source_sha: branch.target) create(:external_pull_request, project: project, source_branch: branch.name, source_sha: branch.target)
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe CleanupContainerRepositoryWorker, :clean_gitlab_redis_shared_state do RSpec.describe CleanupContainerRepositoryWorker, :clean_gitlab_redis_shared_state do
let(:repository) { create(:container_repository) } let(:repository) { create(:container_repository) }
let(:project) { repository.project } let(:project) { repository.project }
let(:user) { project.owner } let(:user) { project.first_owner }
subject { described_class.new } subject { described_class.new }
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe DeleteContainerRepositoryWorker do RSpec.describe DeleteContainerRepositoryWorker do
let(:registry) { create(:container_repository) } let(:registry) { create(:container_repository) }
let(:project) { registry.project } let(:project) { registry.project }
let(:user) { project.owner } let(:user) { project.first_owner }
subject { described_class.new } subject { described_class.new }
......
...@@ -13,11 +13,11 @@ RSpec.describe DeleteMergedBranchesWorker do ...@@ -13,11 +13,11 @@ RSpec.describe DeleteMergedBranchesWorker do
expect(instance).to receive(:execute).and_return(true) expect(instance).to receive(:execute).and_return(true)
end end
worker.perform(project.id, project.owner.id) worker.perform(project.id, project.first_owner.id)
end end
it "returns false when project was not found" do it "returns false when project was not found" do
expect(worker.perform('unknown', project.owner.id)).to be_falsy expect(worker.perform('unknown', project.first_owner.id)).to be_falsy
end end
end end
end end
...@@ -15,7 +15,7 @@ RSpec.describe PostReceive do ...@@ -15,7 +15,7 @@ RSpec.describe PostReceive do
let(:wrongly_encoded_changes) { changes.encode("ISO-8859-1").force_encoding("UTF-8") } let(:wrongly_encoded_changes) { changes.encode("ISO-8859-1").force_encoding("UTF-8") }
let(:base64_changes) { Base64.encode64(wrongly_encoded_changes) } let(:base64_changes) { Base64.encode64(wrongly_encoded_changes) }
let(:gl_repository) { "project-#{project.id}" } let(:gl_repository) { "project-#{project.id}" }
let(:key) { create(:key, user: project.owner) } let(:key) { create(:key, user: project.first_owner) }
let!(:key_id) { key.shell_id } let!(:key_id) { key.shell_id }
let(:project) do let(:project) do
...@@ -47,7 +47,7 @@ RSpec.describe PostReceive do ...@@ -47,7 +47,7 @@ RSpec.describe PostReceive do
context 'with PersonalSnippet' do context 'with PersonalSnippet' do
let(:gl_repository) { "snippet-#{snippet.id}" } let(:gl_repository) { "snippet-#{snippet.id}" }
let(:snippet) { create(:personal_snippet, author: project.owner) } let(:snippet) { create(:personal_snippet, author: project.first_owner) }
it 'does not log an error' do it 'does not log an error' do
expect(Gitlab::GitLogger).not_to receive(:error) expect(Gitlab::GitLogger).not_to receive(:error)
...@@ -60,7 +60,7 @@ RSpec.describe PostReceive do ...@@ -60,7 +60,7 @@ RSpec.describe PostReceive do
context 'with ProjectSnippet' do context 'with ProjectSnippet' do
let(:gl_repository) { "snippet-#{snippet.id}" } let(:gl_repository) { "snippet-#{snippet.id}" }
let(:snippet) { create(:snippet, type: 'ProjectSnippet', project: nil, author: project.owner) } let(:snippet) { create(:snippet, type: 'ProjectSnippet', project: nil, author: project.first_owner) }
it 'returns false and logs an error' do it 'returns false and logs an error' do
expect(Gitlab::GitLogger).to receive(:error).with("POST-RECEIVE: #{error_message}") expect(Gitlab::GitLogger).to receive(:error).with("POST-RECEIVE: #{error_message}")
...@@ -74,7 +74,7 @@ RSpec.describe PostReceive do ...@@ -74,7 +74,7 @@ RSpec.describe PostReceive do
let(:empty_project) { create(:project, :empty_repo) } let(:empty_project) { create(:project, :empty_repo) }
before do before do
allow_next(Gitlab::GitPostReceive).to receive(:identify).and_return(empty_project.owner) allow_next(Gitlab::GitPostReceive).to receive(:identify).and_return(empty_project.first_owner)
# Need to mock here so we can expect calls on project # Need to mock here so we can expect calls on project
allow(Gitlab::GlRepository).to receive(:parse).and_return([empty_project, empty_project, Gitlab::GlRepository::PROJECT]) allow(Gitlab::GlRepository).to receive(:parse).and_return([empty_project, empty_project, Gitlab::GlRepository::PROJECT])
end end
...@@ -128,7 +128,7 @@ RSpec.describe PostReceive do ...@@ -128,7 +128,7 @@ RSpec.describe PostReceive do
let(:push_service) { double(execute: true) } let(:push_service) { double(execute: true) }
before do before do
allow_next(Gitlab::GitPostReceive).to receive(:identify).and_return(project.owner) allow_next(Gitlab::GitPostReceive).to receive(:identify).and_return(project.first_owner)
allow(Gitlab::GlRepository).to receive(:parse).and_return([project, project, Gitlab::GlRepository::PROJECT]) allow(Gitlab::GlRepository).to receive(:parse).and_return([project, project, Gitlab::GlRepository::PROJECT])
end end
...@@ -381,7 +381,7 @@ RSpec.describe PostReceive do ...@@ -381,7 +381,7 @@ RSpec.describe PostReceive do
allow(Project).to receive(:find_by).and_return(project) allow(Project).to receive(:find_by).and_return(project)
expect_next(MergeRequests::PushedBranchesService).to receive(:execute).and_return(%w(tést)) expect_next(MergeRequests::PushedBranchesService).to receive(:execute).and_return(%w(tést))
expect(UpdateMergeRequestsWorker).to receive(:perform_async).with(project.id, project.owner.id, any_args) expect(UpdateMergeRequestsWorker).to receive(:perform_async).with(project.id, project.first_owner.id, any_args)
perform perform
end end
...@@ -461,13 +461,13 @@ RSpec.describe PostReceive do ...@@ -461,13 +461,13 @@ RSpec.describe PostReceive do
end end
context 'with PersonalSnippet' do context 'with PersonalSnippet' do
let!(:snippet) { create(:personal_snippet, :repository, author: project.owner) } let!(:snippet) { create(:personal_snippet, :repository, author: project.first_owner) }
it_behaves_like 'snippet changes actions' it_behaves_like 'snippet changes actions'
end end
context 'with ProjectSnippet' do context 'with ProjectSnippet' do
let!(:snippet) { create(:project_snippet, :repository, project: project, author: project.owner) } let!(:snippet) { create(:project_snippet, :repository, project: project, author: project.first_owner) }
it_behaves_like 'snippet changes actions' it_behaves_like 'snippet changes actions'
end end
......
...@@ -14,7 +14,7 @@ RSpec.describe ProjectDestroyWorker do ...@@ -14,7 +14,7 @@ RSpec.describe ProjectDestroyWorker do
describe '#perform' do describe '#perform' do
it 'deletes the project' do it 'deletes the project' do
subject.perform(project.id, project.owner.id, {}) subject.perform(project.id, project.first_owner.id, {})
expect(Project.all).not_to include(project) expect(Project.all).not_to include(project)
expect(Dir.exist?(path)).to be_falsey expect(Dir.exist?(path)).to be_falsey
...@@ -22,7 +22,7 @@ RSpec.describe ProjectDestroyWorker do ...@@ -22,7 +22,7 @@ RSpec.describe ProjectDestroyWorker do
it 'does not raise error when project could not be found' do it 'does not raise error when project could not be found' do
expect do expect do
subject.perform(-1, project.owner.id, {}) subject.perform(-1, project.first_owner.id, {})
end.not_to raise_error end.not_to raise_error
end end
......
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