Commit 0a45fdb9 authored by Michael Kozono's avatar Michael Kozono

Merge branch 'tle-non-existent-group-merge-request-approval-settings' into 'master'

Return default group MR approval settings

See merge request gitlab-org/gitlab!52880
parents d950faef 32a8bc8f
......@@ -21,8 +21,9 @@ module API
get do
authorize! :admin_merge_request_approval_settings, user_group
present user_group.group_merge_request_approval_setting,
with: ::API::Entities::GroupMergeRequestApprovalSetting
setting = GroupMergeRequestApprovalSetting.find_or_initialize_by_group(user_group)
present setting, with: ::API::Entities::GroupMergeRequestApprovalSetting
end
desc 'Update existing merge request approval setting' do
......
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe API::GroupMergeRequestApprovalSettings do
let_it_be(:group) { create(:group) }
let_it_be_with_reload(:group) { create(:group) }
let_it_be(:user) { create(:user) }
let_it_be(:setting) { create(:group_merge_request_approval_setting, group: group) }
......@@ -47,6 +47,19 @@ RSpec.describe API::GroupMergeRequestApprovalSettings do
expect(response).to match_response_schema('public_api/v4/group_merge_request_approval_settings', dir: 'ee')
end
context 'when the group does not have existing settings' do
before do
group.group_merge_request_approval_setting.delete
end
it 'returns in-memory default settings', :aggregate_failures do
get api(url, user)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['allow_author_approval']).to eq(false)
end
end
end
context 'when the user is not authorised' do
......
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