Commit d51b0c89 authored by jejacks0n's avatar jejacks0n

Add readme in repo creation for reg flow

This adds the ability to have a repo created with a readme associated
with it as part of the registration group and project creation.

Changelog: added
EE: true
parent 884ecd76
......@@ -42,7 +42,7 @@ module Registrations
end
end
@project = ::Projects::CreateService.new(current_user, project_params).execute
@project = ::Projects::CreateService.new(current_user, create_project_params).execute
if @project.saved?
combined_registration_experiment.track(:create_project, namespace: @project.namespace)
......@@ -98,8 +98,12 @@ module Registrations
@combined_registration_experiment ||= experiment(:combined_registration, user: current_user)
end
def project_params
params.require(:project).permit(project_params_attributes).merge(namespace_id: @group.id)
def create_project_params
project_params(:initialize_with_readme)
end
def project_params(*extra)
params.require(:project).permit(project_params_attributes + extra).merge(namespace_id: @group.id)
end
def modified_group_params
......
......@@ -68,6 +68,13 @@
%p.form-text.text-muted.gl-text-center{ class: 'gl-mb-5!' }
= _('You can always change your URL later')
.form-group
.form-check.gl-mb-3
= check_box_tag 'project[initialize_with_readme]', '1', true, class: 'form-check-input'
= label_tag 'project[initialize_with_readme]', s_('ProjectsNew|Include a Getting Started README'), class: 'form-check-label'
.form-text.text-muted
= s_('ProjectsNew|Recommended if you\'re new to GitLab')
= submit_tag _('Create project'), class: 'btn gl-button btn-confirm btn-block', data: { track_label: 'blank_project', track_action: 'click_button', track_property: 'create_project', track_value: '' }
#import-project-pane.tab-pane.import-project-pane.js-toggle-container{ role: 'tabpanel' }
......
......@@ -63,7 +63,7 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do
let(:params) { { group: group_params, project: project_params }.merge(extra_params) }
let(:extra_params) { {} }
let(:group_params) { { name: 'Group name', path: 'group-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s, setup_for_company: setup_for_company } }
let(:project_params) { { name: 'New project', path: 'project-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE } }
let(:project_params) { { name: 'New project', path: 'project-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE, initialize_with_readme: 'true' } }
let(:dev_env_or_com) { true }
let(:setup_for_company) { nil }
let(:combined_registration?) { true }
......@@ -94,6 +94,17 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do
post_create
end
it 'allows for the project to be initialized with a README' do
allow(::Projects::CreateService).to receive(:new).and_call_original # a learn gitlab project is created too
expect(::Projects::CreateService).to receive(:new).with(
user,
an_object_satisfying { |permitted| permitted.include?(:initialize_with_readme) }
)
post_create
end
it 'tracks create events for the combined_registration experiment' do
allow_next_instance_of(::Projects::CreateService) do |service|
allow(service).to receive(:after_create_actions)
......
......@@ -29152,6 +29152,9 @@ msgstr ""
msgid "ProjectsNew|Import project"
msgstr ""
msgid "ProjectsNew|Include a Getting Started README"
msgstr ""
msgid "ProjectsNew|Initialize repository with a README"
msgstr ""
......@@ -29167,6 +29170,9 @@ msgstr ""
msgid "ProjectsNew|Project description %{tag_start}(optional)%{tag_end}"
msgstr ""
msgid "ProjectsNew|Recommended if you're new to GitLab"
msgstr ""
msgid "ProjectsNew|Run CI/CD for external repository"
msgstr ""
......
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