Commit ae407262 authored by Douwe Maan's avatar Douwe Maan Committed by Rémy Coutable

Merge branch 'move-issue-section-should-not-be-displayed-in-the-new-issue-form-14489' into 'master'

Moving of issuables only when the record already exists

Closes #14489

See merge request !3340
parent 0223a2de
......@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.6.1 (unreleased)
- Add option to reload the schema before restoring a database backup. !2807
- Restrict notifications for confidential issues. !3334
- Do not allow to move issue if it has not been persisted. !3340
- Fixes issue with signin button overflowing on mobile. !3342
- Auto collapses the navigation sidebar when resizing. !3343
......
......@@ -146,7 +146,8 @@ class Issue < ActiveRecord::Base
return false unless user.can?(:admin_issue, to_project)
end
!moved? && user.can?(:admin_issue, self.project)
!moved? && persisted? &&
user.can?(:admin_issue, self.project)
end
def to_branch_name
......
......@@ -78,6 +78,8 @@ module Issues
end
def unfold_references(content)
return unless content
rewriter = Gitlab::Gfm::ReferenceRewriter.new(content, @old_project,
@current_user)
rewriter.rewrite(@new_project)
......
......@@ -152,6 +152,11 @@ describe Issue, models: true do
it { is_expected.to eq true }
context 'issue not persisted' do
let(:issue) { build(:issue, project: project) }
it { is_expected.to eq false }
end
context 'checking destination project also' do
subject { issue.can_move?(user, to_project) }
let(:to_project) { create(:project) }
......
......@@ -208,6 +208,12 @@ describe Issues::MoveService, services: true do
it { expect { move }.to raise_error(StandardError, /permissions/) }
end
context 'issue is not persisted' do
include_context 'user can move issue'
let(:old_issue) { build(:issue, project: old_project, author: author) }
it { expect { move }.to raise_error(StandardError, /permissions/) }
end
end
end
end
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