Commit 3de4814e authored by Matthias Käppler's avatar Matthias Käppler

Merge branch 'if-353225-create_project_settings' into 'master'

Create ProjectSetting during project creation

See merge request gitlab-org/gitlab!84502
parents 9b0d474d 384b51d2
...@@ -105,7 +105,8 @@ module Projects ...@@ -105,7 +105,8 @@ module Projects
end end
@project.track_project_repository @project.track_project_repository
@project.create_project_setting unless @project.project_setting
create_project_settings
yield if block_given? yield if block_given?
...@@ -122,6 +123,14 @@ module Projects ...@@ -122,6 +123,14 @@ module Projects
create_sast_commit if @initialize_with_sast create_sast_commit if @initialize_with_sast
end end
def create_project_settings
if Feature.enabled?(:create_project_settings, default_enabled: :yaml)
@project.project_setting.save if @project.project_setting.changed?
else
@project.create_project_setting unless @project.project_setting
end
end
# Add an authorization for the current user authorizations inline # Add an authorization for the current user authorizations inline
# (so they can access the project immediately after this request # (so they can access the project immediately after this request
# completes), and any other affected users in the background # completes), and any other affected users in the background
......
---
name: create_project_settings
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/84502
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/358136
milestone: '14.10'
type: development
group: group::authentication and authorization
default_enabled: false
...@@ -47,7 +47,7 @@ RSpec.describe API::ProjectImport, :aggregate_failures do ...@@ -47,7 +47,7 @@ RSpec.describe API::ProjectImport, :aggregate_failures do
it 'executes a limited number of queries' do it 'executes a limited number of queries' do
control_count = ActiveRecord::QueryRecorder.new { subject }.count control_count = ActiveRecord::QueryRecorder.new { subject }.count
expect(control_count).to be <= 105 expect(control_count).to be <= 108
end end
it 'schedules an import using a namespace' do it 'schedules an import using a namespace' do
......
...@@ -135,11 +135,23 @@ RSpec.describe Projects::CreateService, '#execute' do ...@@ -135,11 +135,23 @@ RSpec.describe Projects::CreateService, '#execute' do
create_project(user, opts) create_project(user, opts)
end end
it 'creates associated project settings' do
project = create_project(user, opts)
expect(project.project_setting).to be_persisted
end
context 'create_project_settings feature flag is disabled' do
before do
stub_feature_flags(create_project_settings: false)
end
it 'builds associated project settings' do it 'builds associated project settings' do
project = create_project(user, opts) project = create_project(user, opts)
expect(project.project_setting).to be_new_record expect(project.project_setting).to be_new_record
end end
end
it_behaves_like 'storing arguments in the application context' do it_behaves_like 'storing arguments in the application context' do
let(:expected_params) { { project: subject.full_path } } let(:expected_params) { { project: subject.full_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