Commit 7ff1e6f8 authored by Stan Hu's avatar Stan Hu

Merge branch...

Merge branch '324087-change-default-value-to-merge_requests_author_approval-on-projects' into 'master'

Add default value for merge_requests_author_approval

See merge request gitlab-org/gitlab!61949
parents 26a013c9 cfee7a8b
......@@ -2606,6 +2606,10 @@ class Project < ApplicationRecord
ProjectStatistics.increment_statistic(self, statistic, delta)
end
def merge_requests_author_approval
!!read_attribute(:merge_requests_author_approval)
end
private
def set_container_registry_access_level
......
# frozen_string_literal: true
class AddDefaultValueToMergeRequestsAuthorApprovalOnProjects < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
def up
with_lock_retries do
change_column_default :projects, :merge_requests_author_approval, false
end
end
def down
with_lock_retries do
change_column_default :projects, :merge_requests_author_approval, nil
end
end
end
69e7297ace1301bbdb63053bd30b75c326122873fbc6c5c15f9f118166111434
\ No newline at end of file
......@@ -16997,7 +16997,7 @@ CREATE TABLE projects (
pages_https_only boolean DEFAULT true,
external_webhook_token character varying,
packages_enabled boolean,
merge_requests_author_approval boolean,
merge_requests_author_approval boolean DEFAULT false,
pool_repository_id bigint,
runners_token_encrypted character varying,
bfg_object_map character varying,
......@@ -496,7 +496,7 @@ RSpec.describe ProjectsController do
project.reload
expect(project[setting]).to eq(final_value)
expect(project[setting]).to eq(final_value.nil? ? setting_default_value : final_value)
end
end
end
......@@ -505,6 +505,7 @@ RSpec.describe ProjectsController do
it_behaves_like 'merge request approvers rules' do
let(:rule_name) { :modify_approvers_rules }
let(:setting) { :disable_overriding_approvers_per_merge_request }
let(:setting_default_value) { nil }
end
end
......@@ -512,6 +513,7 @@ RSpec.describe ProjectsController do
it_behaves_like 'merge request approvers rules' do
let(:rule_name) { :modify_merge_request_author_setting }
let(:setting) { :merge_requests_author_approval }
let(:setting_default_value) { false }
end
end
......@@ -519,6 +521,7 @@ RSpec.describe ProjectsController do
it_behaves_like 'merge request approvers rules' do
let(:rule_name) { :modify_merge_request_committer_setting }
let(:setting) { :merge_requests_disable_committers_approval }
let(:setting_default_value) { nil }
end
end
end
......
......@@ -472,6 +472,23 @@ RSpec.describe Project, factory_default: :keep do
end
end
describe '#merge_requests_author_approval' do
where(:attribute_value, :return_value) do
true | true
false | false
nil | false
end
with_them do
let(:project) { create(:project, merge_requests_author_approval: attribute_value) }
it 'returns expected value' do
expect(project.merge_requests_author_approval).to eq(return_value)
expect(project.merge_requests_author_approval?).to eq(return_value)
end
end
end
describe '#all_pipelines' do
let_it_be(:project) { create(:project) }
......
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