2020-01-01 13:55:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-03-17 16:20:25 +05:30
|
|
|
RSpec.describe 'merge requests creations', feature_category: :code_review_workflow do
|
2020-01-01 13:55:28 +05:30
|
|
|
describe 'GET /:namespace/:project/merge_requests/new' do
|
|
|
|
include ProjectForksHelper
|
|
|
|
|
|
|
|
let(:project) { create(:project, :repository) }
|
2022-04-04 11:22:00 +05:30
|
|
|
let(:user) { project.first_owner }
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
login_as(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_new
|
|
|
|
get namespace_project_new_merge_request_path(namespace_id: project.namespace, project_id: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'avoids N+1 DB queries even with forked projects' do
|
|
|
|
control = ActiveRecord::QueryRecorder.new(skip_cached: false) { get_new }
|
|
|
|
|
|
|
|
5.times { fork_project(project, user) }
|
|
|
|
|
|
|
|
expect { get_new }.not_to exceed_query_limit(control)
|
|
|
|
end
|
2023-03-04 22:38:38 +05:30
|
|
|
|
|
|
|
it_behaves_like "observability csp policy", Projects::MergeRequests::CreationsController do
|
2023-03-17 16:20:25 +05:30
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:project) { create(:project, group: group) }
|
2023-03-04 22:38:38 +05:30
|
|
|
let(:tested_path) do
|
|
|
|
project_new_merge_request_path(project, merge_request: {
|
2023-03-17 16:20:25 +05:30
|
|
|
title: 'Some feature',
|
|
|
|
source_branch: 'fix',
|
|
|
|
target_branch: 'feature',
|
|
|
|
target_project: project,
|
|
|
|
source_project: project
|
|
|
|
})
|
2023-03-04 22:38:38 +05:30
|
|
|
end
|
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
|
|
|
end
|