diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-03-23 10:29:26 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-03-23 12:29:41 +0100 |
commit | ae407262f2763b153fa3d1fce3c6363ae2296618 (patch) | |
tree | 5c202315eafea687d3e599abd60c640325876e98 | |
parent | 0223a2de921401fbbf51e28139fe3bf0e593050d (diff) | |
download | gitlab-ce-ae407262f2763b153fa3d1fce3c6363ae2296618.tar.gz |
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
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/models/issue.rb | 3 | ||||
-rw-r--r-- | app/services/issues/move_service.rb | 2 | ||||
-rw-r--r-- | spec/models/issue_spec.rb | 5 | ||||
-rw-r--r-- | spec/services/issues/move_service_spec.rb | 6 |
5 files changed, 16 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG index 7e269eefcd5..f5a69180487 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/app/models/issue.rb b/app/models/issue.rb index f32db59ac9f..ed960cb39f4 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -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 diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb index 3cfbafe1576..468f8acdf64 100644 --- a/app/services/issues/move_service.rb +++ b/app/services/issues/move_service.rb @@ -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) diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 3c34b1d397f..15052aaca28 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -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) } diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb index 14cc20e529a..ade3b7850f1 100644 --- a/spec/services/issues/move_service_spec.rb +++ b/spec/services/issues/move_service_spec.rb @@ -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 |