Commit 09d5bf5e authored by charlie ablett's avatar charlie ablett Committed by Alex Kalderimis

Replace owner with first_owner in request specs

parent f62b6a67
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe BlobPresenter do RSpec.describe BlobPresenter 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(:repository) { project.repository } let(:repository) { project.repository }
let(:blob) { repository.blob_at('HEAD', 'files/ruby/regex.rb') } let(:blob) { repository.blob_at('HEAD', 'files/ruby/regex.rb') }
......
...@@ -102,7 +102,7 @@ RSpec.describe API::API do ...@@ -102,7 +102,7 @@ RSpec.describe API::API do
describe 'logging', :aggregate_failures do describe 'logging', :aggregate_failures do
let_it_be(:project) { create(:project, :public) } let_it_be(:project) { create(:project, :public) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
context 'when the endpoint is handled by the application' do context 'when the endpoint is handled by the application' do
context 'when the endpoint supports all possible fields' do context 'when the endpoint supports all possible fields' do
......
...@@ -988,7 +988,7 @@ RSpec.describe API::Ci::Pipelines do ...@@ -988,7 +988,7 @@ RSpec.describe API::Ci::Pipelines do
describe 'DELETE /projects/:id/pipelines/:pipeline_id' do describe 'DELETE /projects/:id/pipelines/:pipeline_id' do
context 'authorized user' do context 'authorized user' do
let(:owner) { project.owner } let(:owner) { project.first_owner }
it 'destroys the pipeline' do it 'destroys the pipeline' do
delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner) delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner)
......
...@@ -138,7 +138,7 @@ RSpec.describe API::Ci::Runners do ...@@ -138,7 +138,7 @@ RSpec.describe API::Ci::Runners do
end end
include_context 'when authorized', 'project' do include_context 'when authorized', 'project' do
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
def get_token def get_token
project.reload.runners_token project.reload.runners_token
......
...@@ -5,7 +5,7 @@ RSpec.describe 'Getting Ci Cd Setting' do ...@@ -5,7 +5,7 @@ RSpec.describe 'Getting Ci Cd Setting' do
include GraphqlHelpers include GraphqlHelpers
let_it_be_with_reload(:project) { create(:project, :repository) } let_it_be_with_reload(:project) { create(:project, :repository) }
let_it_be(:current_user) { project.owner } let_it_be(:current_user) { project.first_owner }
let(:fields) do let(:fields) do
<<~QUERY <<~QUERY
......
...@@ -17,7 +17,7 @@ RSpec.describe 'container repository details' do ...@@ -17,7 +17,7 @@ RSpec.describe 'container repository details' do
) )
end end
let(:user) { project.owner } let(:user) { project.first_owner }
let(:variables) { {} } let(:variables) { {} }
let(:tags) { %w[latest tag1 tag2 tag3 tag4 tag5] } let(:tags) { %w[latest tag1 tag2 tag3 tag4 tag5] }
let(:container_repository_global_id) { container_repository.to_global_id.to_s } let(:container_repository_global_id) { container_repository.to_global_id.to_s }
......
...@@ -166,7 +166,7 @@ RSpec.describe 'GitlabSchema configurations' do ...@@ -166,7 +166,7 @@ RSpec.describe 'GitlabSchema configurations' do
end end
context 'authentication' do context 'authentication' do
let(:current_user) { project.owner } let(:current_user) { project.first_owner }
it 'authenticates all queries' do it 'authenticates all queries' do
subject subject
...@@ -216,7 +216,7 @@ RSpec.describe 'GitlabSchema configurations' do ...@@ -216,7 +216,7 @@ RSpec.describe 'GitlabSchema configurations' do
context "global id's" do context "global id's" do
it 'uses GlobalID to expose ids' do it 'uses GlobalID to expose ids' do
post_graphql(graphql_query_for('project', { 'fullPath' => project.full_path }, %w(id)), post_graphql(graphql_query_for('project', { 'fullPath' => project.full_path }, %w(id)),
current_user: project.owner) current_user: project.first_owner)
parsed_id = GlobalID.parse(graphql_data['project']['id']) parsed_id = GlobalID.parse(graphql_data['project']['id'])
......
...@@ -45,7 +45,7 @@ RSpec.describe 'CiCdSettingsUpdate' do ...@@ -45,7 +45,7 @@ RSpec.describe 'CiCdSettingsUpdate' do
end end
context 'when authorized' do context 'when authorized' do
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
it 'updates ci cd settings' do it 'updates ci cd settings' do
post_graphql_mutation(mutation, current_user: user) post_graphql_mutation(mutation, current_user: user)
......
...@@ -49,7 +49,7 @@ RSpec.describe 'CiJobTokenScopeAddProject' do ...@@ -49,7 +49,7 @@ RSpec.describe 'CiJobTokenScopeAddProject' do
end end
context 'when authorized' do context 'when authorized' do
let_it_be(:current_user) { project.owner } let_it_be(:current_user) { project.first_owner }
before do before do
target_project.add_developer(current_user) target_project.add_developer(current_user)
......
...@@ -55,7 +55,7 @@ RSpec.describe 'CiJobTokenScopeRemoveProject' do ...@@ -55,7 +55,7 @@ RSpec.describe 'CiJobTokenScopeRemoveProject' do
end end
context 'when authorized' do context 'when authorized' do
let_it_be(:current_user) { project.owner } let_it_be(:current_user) { project.first_owner }
before do before do
target_project.add_guest(current_user) target_project.add_guest(current_user)
......
...@@ -6,7 +6,7 @@ RSpec.describe 'PipelineDestroy' do ...@@ -6,7 +6,7 @@ RSpec.describe 'PipelineDestroy' do
include GraphqlHelpers include GraphqlHelpers
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_it_be(:pipeline) { create(:ci_pipeline, :success, project: project, user: user) } let_it_be(:pipeline) { create(:ci_pipeline, :success, project: project, user: user) }
let(:mutation) do let(:mutation) do
......
...@@ -71,7 +71,7 @@ RSpec.describe 'RunnersRegistrationTokenReset' do ...@@ -71,7 +71,7 @@ RSpec.describe 'RunnersRegistrationTokenReset' do
end end
include_context 'when authorized', 'project' do include_context 'when authorized', 'project' do
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
def get_token def get_token
project.reload.runners_token project.reload.runners_token
......
...@@ -12,7 +12,7 @@ RSpec.describe 'ConfigureSastIac' do ...@@ -12,7 +12,7 @@ RSpec.describe 'ConfigureSastIac' do
let(:mutation_response) { graphql_mutation_response(:configureSastIac) } let(:mutation_response) { graphql_mutation_response(:configureSastIac) }
context 'when authorized' do context 'when authorized' do
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
it 'creates a branch with sast iac configured' do it 'creates a branch with sast iac configured' do
post_graphql_mutation(mutation, current_user: user) post_graphql_mutation(mutation, current_user: user)
......
...@@ -12,7 +12,7 @@ RSpec.describe 'ConfigureSecretDetection' do ...@@ -12,7 +12,7 @@ RSpec.describe 'ConfigureSecretDetection' do
let(:mutation_response) { graphql_mutation_response(:configureSecretDetection) } let(:mutation_response) { graphql_mutation_response(:configureSecretDetection) }
context 'when authorized' do context 'when authorized' do
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
it 'creates a branch with secret detection configured' do it 'creates a branch with secret detection configured' do
post_graphql_mutation(mutation, current_user: user) post_graphql_mutation(mutation, current_user: user)
......
...@@ -5,7 +5,7 @@ RSpec.describe 'getting a repository in a project' do ...@@ -5,7 +5,7 @@ RSpec.describe 'getting a repository in a project' do
include GraphqlHelpers include GraphqlHelpers
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:current_user) { project.owner } let_it_be(:current_user) { project.first_owner }
let_it_be(:container_expiration_policy) { project.container_expiration_policy } let_it_be(:container_expiration_policy) { project.container_expiration_policy }
let(:fields) do let(:fields) do
......
...@@ -38,7 +38,7 @@ RSpec.describe 'getting container repositories in a project' do ...@@ -38,7 +38,7 @@ RSpec.describe 'getting container repositories in a project' do
) )
end end
let(:user) { project.owner } let(:user) { project.first_owner }
let(:variables) { {} } let(:variables) { {} }
let(:container_repositories_response) { graphql_data.dig('project', 'containerRepositories', 'edges') } let(:container_repositories_response) { graphql_data.dig('project', 'containerRepositories', 'edges') }
let(:container_repositories_count_response) { graphql_data.dig('project', 'containerRepositoriesCount') } let(:container_repositories_count_response) { graphql_data.dig('project', 'containerRepositoriesCount') }
......
...@@ -6,7 +6,7 @@ RSpec.describe 'getting a detailed sentry error' do ...@@ -6,7 +6,7 @@ RSpec.describe 'getting a detailed sentry error' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:project_setting) { create(:project_error_tracking_setting, project: project) } let_it_be(:project_setting) { create(:project_error_tracking_setting, project: project) }
let_it_be(:current_user) { project.owner } let_it_be(:current_user) { project.first_owner }
let_it_be(:sentry_detailed_error) { build(:error_tracking_sentry_detailed_error) } let_it_be(:sentry_detailed_error) { build(:error_tracking_sentry_detailed_error) }
let(:sentry_gid) { sentry_detailed_error.to_global_id.to_s } let(:sentry_gid) { sentry_detailed_error.to_global_id.to_s }
......
...@@ -6,7 +6,7 @@ RSpec.describe 'sentry errors requests' do ...@@ -6,7 +6,7 @@ RSpec.describe 'sentry errors requests' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:project_setting) { create(:project_error_tracking_setting, project: project) } let_it_be(:project_setting) { create(:project_error_tracking_setting, project: project) }
let_it_be(:current_user) { project.owner } let_it_be(:current_user) { project.first_owner }
let(:query) do let(:query) do
graphql_query_for( graphql_query_for(
......
...@@ -5,7 +5,7 @@ RSpec.describe 'Getting Grafana Integration' do ...@@ -5,7 +5,7 @@ RSpec.describe 'Getting Grafana Integration' do
include GraphqlHelpers include GraphqlHelpers
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:current_user) { project.owner } let_it_be(:current_user) { project.first_owner }
let_it_be(:grafana_integration) { create(:grafana_integration, project: project) } let_it_be(:grafana_integration) { create(:grafana_integration, project: project) }
let(:fields) do let(:fields) do
......
...@@ -24,7 +24,7 @@ RSpec.describe 'Getting versions related to an issue' do ...@@ -24,7 +24,7 @@ RSpec.describe 'Getting versions related to an issue' do
create(:design_version, issue: issue) create(:design_version, issue: issue)
end end
let_it_be(:owner) { issue.project.owner } let_it_be(:owner) { issue.project.first_owner }
def version_query(params = version_params) def version_query(params = version_params)
query_graphql_field(:versions, params, version_query_fields) query_graphql_field(:versions, params, version_query_fields)
......
...@@ -7,7 +7,7 @@ RSpec.describe 'Getting designs related to an issue' do ...@@ -7,7 +7,7 @@ RSpec.describe 'Getting designs related to an issue' do
include DesignManagementTestHelpers include DesignManagementTestHelpers
let_it_be(:design) { create(:design, :with_smaller_image_versions, versions_count: 1) } let_it_be(:design) { create(:design, :with_smaller_image_versions, versions_count: 1) }
let_it_be(:current_user) { design.project.owner } let_it_be(:current_user) { design.project.first_owner }
let(:design_query) do let(:design_query) do
<<~NODE <<~NODE
......
...@@ -9,7 +9,7 @@ RSpec.describe 'Getting designs related to an issue' do ...@@ -9,7 +9,7 @@ RSpec.describe 'Getting designs related to an issue' do
let_it_be(:project) { create(:project, :public) } let_it_be(:project) { create(:project, :public) }
let_it_be(:issue) { create(:issue, project: project) } let_it_be(:issue) { create(:issue, project: project) }
let_it_be(:design) { create(:design, :with_file, versions_count: 1, issue: issue) } let_it_be(:design) { create(:design, :with_file, versions_count: 1, issue: issue) }
let_it_be(:current_user) { project.owner } let_it_be(:current_user) { project.first_owner }
let_it_be(:note) { create(:diff_note_on_design, noteable: design, project: project) } let_it_be(:note) { create(:diff_note_on_design, noteable: design, project: project) }
before do before do
......
...@@ -5,7 +5,7 @@ RSpec.describe 'getting blobs in a project repository' do ...@@ -5,7 +5,7 @@ RSpec.describe 'getting blobs in a project repository' do
include GraphqlHelpers include GraphqlHelpers
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:current_user) { project.owner } let(:current_user) { project.first_owner }
let(:paths) { ["CONTRIBUTING.md", "README.md"] } let(:paths) { ["CONTRIBUTING.md", "README.md"] }
let(:ref) { project.default_branch } let(:ref) { project.default_branch }
let(:fields) do let(:fields) do
......
...@@ -5,7 +5,7 @@ RSpec.describe 'getting a repository in a project' do ...@@ -5,7 +5,7 @@ RSpec.describe 'getting a repository in a project' do
include GraphqlHelpers include GraphqlHelpers
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:current_user) { project.owner } let(:current_user) { project.first_owner }
let(:fields) do let(:fields) do
<<~QUERY <<~QUERY
#{all_graphql_fields_for('repository'.classify)} #{all_graphql_fields_for('repository'.classify)}
......
...@@ -5,7 +5,7 @@ RSpec.describe 'getting a tree in a project' do ...@@ -5,7 +5,7 @@ RSpec.describe 'getting a tree in a project' do
include GraphqlHelpers include GraphqlHelpers
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:current_user) { project.owner } let(:current_user) { project.first_owner }
let(:path) { "" } let(:path) { "" }
let(:ref) { "master" } let(:ref) { "master" }
let(:fields) do let(:fields) do
......
...@@ -71,7 +71,7 @@ RSpec.describe API::Markdown do ...@@ -71,7 +71,7 @@ RSpec.describe API::Markdown do
end end
context "when authorized" do context "when authorized" do
let(:user) { project.owner } let(:user) { project.first_owner }
it_behaves_like "rendered markdown text without GFM" it_behaves_like "rendered markdown text without GFM"
end end
...@@ -97,7 +97,7 @@ RSpec.describe API::Markdown do ...@@ -97,7 +97,7 @@ RSpec.describe API::Markdown do
context "with project" do context "with project" do
let(:params) { { text: text, gfm: true, project: project.full_path } } let(:params) { { text: text, gfm: true, project: project.full_path } }
let(:user) { project.owner } let(:user) { project.first_owner }
it "renders markdown text" do it "renders markdown text" do
expect(response).to have_gitlab_http_status(:created) expect(response).to have_gitlab_http_status(:created)
......
...@@ -2896,7 +2896,7 @@ RSpec.describe API::MergeRequests do ...@@ -2896,7 +2896,7 @@ RSpec.describe API::MergeRequests do
it 'is false for an unauthorized user' do it 'is false for an unauthorized user' do
expect do expect do
put api("/projects/#{target_project.id}/merge_requests/#{merge_request.iid}", target_project.owner), params: { state_event: 'close', remove_source_branch: true } put api("/projects/#{target_project.id}/merge_requests/#{merge_request.iid}", target_project.first_owner), params: { state_event: 'close', remove_source_branch: true }
end.not_to change { merge_request.reload.merge_params } end.not_to change { merge_request.reload.merge_params }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
......
...@@ -450,7 +450,7 @@ RSpec.describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -450,7 +450,7 @@ RSpec.describe API::ProjectExport, :clean_gitlab_redis_cache do
expect_next_instance_of(Projects::ImportExport::ExportService) do |service| expect_next_instance_of(Projects::ImportExport::ExportService) do |service|
expect(service).to receive(:execute) expect(service).to receive(:execute)
end end
post api(path, project.owner), params: params post api(path, project.first_owner), params: params
expect(response).to have_gitlab_http_status(:accepted) expect(response).to have_gitlab_http_status(:accepted)
end end
......
...@@ -33,7 +33,7 @@ RSpec.describe API::ProjectSnapshots do ...@@ -33,7 +33,7 @@ RSpec.describe API::ProjectSnapshots do
end end
it 'returns authentication error as project owner' do it 'returns authentication error as project owner' do
get api("/projects/#{project.id}/snapshot", project.owner) get api("/projects/#{project.id}/snapshot", project.first_owner)
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
end end
......
...@@ -30,7 +30,7 @@ RSpec.shared_examples 'languages and percentages JSON response' do ...@@ -30,7 +30,7 @@ RSpec.shared_examples 'languages and percentages JSON response' do
context 'when the languages were detected before' do context 'when the languages were detected before' do
before do before do
Projects::DetectRepositoryLanguagesService.new(project, project.owner).execute Projects::DetectRepositoryLanguagesService.new(project, project.first_owner).execute
end end
it 'returns the detection from the database' do it 'returns the detection from the database' do
...@@ -2710,7 +2710,7 @@ RSpec.describe API::Projects do ...@@ -2710,7 +2710,7 @@ RSpec.describe API::Projects do
it 'returns the project users' do it 'returns the project users' do
get api("/projects/#{project.id}/users", current_user) get api("/projects/#{project.id}/users", current_user)
user = project.namespace.owner user = project.namespace.first_owner
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Boards::ListsController do RSpec.describe Boards::ListsController do
describe '#index' do describe '#index' do
let(:board) { create(:board) } let(:board) { create(:board) }
let(:user) { board.project.owner } let(:user) { board.project.first_owner }
it 'does not have N+1 queries' do it 'does not have N+1 queries' do
login_as(user) login_as(user)
......
...@@ -8,7 +8,7 @@ RSpec.describe Import::GitlabProjectsController do ...@@ -8,7 +8,7 @@ RSpec.describe Import::GitlabProjectsController do
include_context 'workhorse headers' include_context 'workhorse headers'
let_it_be(:namespace) { create(:namespace) } let_it_be(:namespace) { create(:namespace) }
let_it_be(:user) { namespace.owner } let_it_be(:user) { namespace.first_owner }
before do before do
login_as(user) login_as(user)
......
...@@ -28,7 +28,7 @@ RSpec.describe Projects::Clusters::IntegrationsController do ...@@ -28,7 +28,7 @@ RSpec.describe Projects::Clusters::IntegrationsController do
describe 'POST create_or_update' do describe 'POST create_or_update' do
let(:cluster) { create(:cluster, :project, :provided_by_gcp) } let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project } let(:project) { cluster.project }
let(:user) { project.owner } let(:user) { project.first_owner }
it_behaves_like '#create_or_update action' do it_behaves_like '#create_or_update action' do
let(:path) { create_or_update_project_cluster_integration_path(project, cluster) } let(:path) { create_or_update_project_cluster_integration_path(project, cluster) }
......
...@@ -7,7 +7,7 @@ RSpec.describe 'merge requests creations' do ...@@ -7,7 +7,7 @@ RSpec.describe 'merge requests creations' do
include ProjectForksHelper include ProjectForksHelper
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { project.owner } let(:user) { project.first_owner }
before do before do
login_as(user) login_as(user)
......
...@@ -6,7 +6,7 @@ RSpec.describe 'merge requests discussions' do ...@@ -6,7 +6,7 @@ RSpec.describe 'merge requests discussions' do
# Further tests can be found at merge_requests_controller_spec.rb # Further tests can be found at merge_requests_controller_spec.rb
describe 'GET /:namespace/:project/-/merge_requests/:iid/discussions' do describe 'GET /:namespace/:project/-/merge_requests/:iid/discussions' do
let(:project) { create(:project, :repository, :public) } let(:project) { create(:project, :repository, :public) }
let(:owner) { project.owner } let(:owner) { project.first_owner }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) } let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) }
......
...@@ -12,7 +12,7 @@ RSpec.describe 'merge requests actions' do ...@@ -12,7 +12,7 @@ RSpec.describe 'merge requests actions' do
reviewers: [user2]) reviewers: [user2])
end end
let(:user) { project.owner } let(:user) { project.first_owner }
let(:user2) { create(:user) } let(:user2) { create(:user) }
before do before do
......
...@@ -6,7 +6,7 @@ RSpec.describe 'Projects::MetricsDashboardController' do ...@@ -6,7 +6,7 @@ RSpec.describe 'Projects::MetricsDashboardController' do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:environment) { create(:environment, project: project) } let_it_be(:environment) { create(:environment, project: project) }
let_it_be(:environment2) { create(:environment, project: project) } let_it_be(:environment2) { create(:environment, project: project) }
let_it_be(:user) { project.owner } let_it_be(:user) { project.first_owner }
before do before do
project.add_developer(user) project.add_developer(user)
......
...@@ -9,7 +9,7 @@ RSpec.describe 'Project noteable notes' do ...@@ -9,7 +9,7 @@ RSpec.describe 'Project noteable notes' do
let(:etag_store) { Gitlab::EtagCaching::Store.new } let(:etag_store) { Gitlab::EtagCaching::Store.new }
let(:notes_path) { project_noteable_notes_path(project, target_type: merge_request.class.name.underscore, target_id: merge_request.id) } let(:notes_path) { project_noteable_notes_path(project, target_type: merge_request.class.name.underscore, target_id: merge_request.id) }
let(:project) { merge_request.project } let(:project) { merge_request.project }
let(:user) { project.owner } let(:user) { project.first_owner }
let(:response_etag) { response.headers['ETag'] } let(:response_etag) { response.headers['ETag'] }
let(:stored_etag) { "W/\"#{etag_store.get(notes_path)}\"" } let(:stored_etag) { "W/\"#{etag_store.get(notes_path)}\"" }
......
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