Commit b51eb228 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 0562cb09089e
......@@ -107,4 +107,27 @@
expect(project.printing_merge_request_link_enabled).to be(false)
end
end
describe 'Checkbox to remove source branch after merge', :js do
it 'is initially checked' do
checkbox = find_field('project_remove_source_branch_after_merge')
expect(checkbox).to be_checked
end
it 'when unchecked sets :remove_source_branch_after_merge to false' do
uncheck('project_remove_source_branch_after_merge')
within('.merge-request-settings-form') do
find('.qa-save-merge-request-changes')
click_on('Save changes')
end
find('.flash-notice')
checkbox = find_field('project_remove_source_branch_after_merge')
expect(checkbox).not_to be_checked
project.reload
expect(project.remove_source_branch_after_merge).to be(false)
end
end
end
......@@ -23,6 +23,7 @@
only_allow_merge_if_all_discussions_are_resolved printing_merge_request_link_enabled
namespace group statistics repository merge_requests merge_request issues
issue pipelines
removeSourceBranchAfterMerge
]
is_expected.to have_graphql_fields(*expected_fields)
......
......@@ -91,15 +91,26 @@ def expect_error_log
end
end
context 'when no model found for the upload' do
context 'when no note found for the upload' do
before do
legacy_upload.model = nil
legacy_upload.model_id = nil
legacy_upload.model_type = 'Note'
expect_error_log
end
it_behaves_like 'legacy upload deletion'
end
context 'when upload does not belong to a note' do
before do
legacy_upload.model = create(:appearance)
end
it 'does not remove the upload' do
expect { described_class.new(legacy_upload).execute }.not_to change { Upload.count }
end
end
context 'when the upload move fails' do
before do
expect(FileUploader).to receive(:copy_to).and_raise('failed')
......
......@@ -35,6 +35,8 @@ def create_upload(model, with_file = true)
let!(:legacy_upload_no_file) { create_upload(note2, false) }
let!(:legacy_upload_legacy_project) { create_upload(note_legacy) }
let!(:appearance) { create(:appearance, :with_logo) }
let(:start_id) { 1 }
let(:end_id) { 10000 }
......@@ -52,12 +54,18 @@ def create_upload(model, with_file = true)
expect(File.exist?(legacy_upload_legacy_project.absolute_path)).to be_falsey
end
it 'removes all AttachmentUploader records' do
expect { subject }.to change { Upload.where(uploader: 'AttachmentUploader').count }.from(3).to(0)
it 'removes all Note AttachmentUploader records' do
expect { subject }.to change { Upload.where(uploader: 'AttachmentUploader').count }.from(4).to(1)
end
it 'creates new uploads for successfully migrated records' do
expect { subject }.to change { Upload.where(uploader: 'FileUploader').count }.from(0).to(2)
end
it 'does not remove appearance uploads' do
subject
expect(appearance.logo.file).to exist
end
end
# rubocop: enable RSpec/FactoriesInMigrationSpecs
......@@ -421,6 +421,7 @@ project:
- pages_metadatum
- alerts_service
- grafana_integration
- remove_source_branch_after_merge
award_emoji:
- awardable
- user
......
......@@ -512,6 +512,7 @@ Project:
- request_access_enabled
- has_external_wiki
- only_allow_merge_if_all_discussions_are_resolved
- remove_source_branch_after_merge
- auto_cancel_pending_pipelines
- printing_merge_request_link_enabled
- resolve_outdated_diff_discussions
......
# frozen_string_literal: true
require 'spec_helper'
describe ReleasePresenter do
include Gitlab::Routing.url_helpers
let_it_be(:project) { create(:project, :repository) }
let(:developer) { create(:user) }
let(:guest) { create(:user) }
let(:user) { developer }
let(:release) { create(:release, project: project) }
let(:presenter) { described_class.new(release, current_user: user) }
before do
project.add_developer(developer)
project.add_guest(guest)
end
describe '#commit_path' do
subject { presenter.commit_path }
it 'returns commit path' do
is_expected.to eq(project_commit_path(project, release.commit.id))
end
context 'when commit is not found' do
let(:release) { create(:release, project: project, sha: 'not-found') }
it { is_expected.to be_nil }
end
context 'when user is guest' do
let(:user) { guest }
it { is_expected.to be_nil }
end
end
describe '#tag_path' do
subject { presenter.tag_path }
it 'returns tag path' do
is_expected.to eq(project_tag_path(project, release.tag))
end
context 'when user is guest' do
let(:user) { guest }
it { is_expected.to be_nil }
end
end
describe '#merge_requests_url' do
subject { presenter.merge_requests_url }
it 'returns merge requests url' do
is_expected.to match /#{project_merge_requests_url(project)}/
end
context 'when release_mr_issue_urls feature flag is disabled' do
before do
stub_feature_flags(release_mr_issue_urls: false)
end
it { is_expected.to be_nil }
end
end
describe '#issues_url' do
subject { presenter.issues_url }
it 'returns merge requests url' do
is_expected.to match /#{project_issues_url(project)}/
end
context 'when release_mr_issue_urls feature flag is disabled' do
before do
stub_feature_flags(release_mr_issue_urls: false)
end
it { is_expected.to be_nil }
end
end
end
......@@ -606,6 +606,7 @@
merge_requests_enabled: false,
wiki_enabled: false,
resolve_outdated_diff_discussions: false,
remove_source_branch_after_merge: true,
only_allow_merge_if_pipeline_succeeds: false,
request_access_enabled: true,
only_allow_merge_if_all_discussions_are_resolved: false,
......@@ -722,6 +723,22 @@
expect(json_response['resolve_outdated_diff_discussions']).to be_truthy
end
it 'sets a project as not removing source branches' do
project = attributes_for(:project, remove_source_branch_after_merge: false)
post api('/projects', user), params: project
expect(json_response['remove_source_branch_after_merge']).to be_falsey
end
it 'sets a project as removing source branches' do
project = attributes_for(:project, remove_source_branch_after_merge: true)
post api('/projects', user), params: project
expect(json_response['remove_source_branch_after_merge']).to be_truthy
end
it 'sets a project as allowing merge even if build fails' do
project = attributes_for(:project, only_allow_merge_if_pipeline_succeeds: false)
......@@ -980,6 +997,22 @@
expect(json_response['resolve_outdated_diff_discussions']).to be_truthy
end
it 'sets a project as not removing source branches' do
project = attributes_for(:project, remove_source_branch_after_merge: false)
post api("/projects/user/#{user.id}", admin), params: project
expect(json_response['remove_source_branch_after_merge']).to be_falsey
end
it 'sets a project as removing source branches' do
project = attributes_for(:project, remove_source_branch_after_merge: true)
post api("/projects/user/#{user.id}", admin), params: project
expect(json_response['remove_source_branch_after_merge']).to be_truthy
end
it 'sets a project as allowing merge even if build fails' do
project = attributes_for(:project, only_allow_merge_if_pipeline_succeeds: false)
post api("/projects/user/#{user.id}", admin), params: project
......@@ -1157,6 +1190,7 @@
expect(json_response['wiki_access_level']).to be_present
expect(json_response['builds_access_level']).to be_present
expect(json_response['resolve_outdated_diff_discussions']).to eq(project.resolve_outdated_diff_discussions)
expect(json_response['remove_source_branch_after_merge']).to be_truthy
expect(json_response['container_registry_enabled']).to be_present
expect(json_response['created_at']).to be_present
expect(json_response['last_activity_at']).to be_present
......
......@@ -80,7 +80,7 @@ def stub_compare
end
it 'does not assign force_remove_source_branch' do
expect(merge_request.force_remove_source_branch?).to be_falsey
expect(merge_request.force_remove_source_branch?).to be_truthy
end
context 'with force_remove_source_branch parameter' do
......@@ -90,6 +90,36 @@ def stub_compare
it 'assigns force_remove_source_branch' do
expect(merge_request.force_remove_source_branch?).to be_truthy
end
context 'with project setting remove_source_branch_after_merge false' do
before do
project.remove_source_branch_after_merge = false
end
it 'assigns force_remove_source_branch' do
expect(merge_request.force_remove_source_branch?).to be_truthy
end
end
end
context 'with project setting remove_source_branch_after_merge true' do
before do
project.remove_source_branch_after_merge = true
end
it 'assigns force_remove_source_branch' do
expect(merge_request.force_remove_source_branch?).to be_truthy
end
context 'with force_remove_source_branch parameter false' do
before do
params[:force_remove_source_branch] = '0'
end
it 'does not assign force_remove_source_branch' do
expect(merge_request.force_remove_source_branch?).to be(false)
end
end
end
context 'missing source branch' 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