Skip to content
Snippets Groups Projects
Commit 915bfedf authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Do not allow to move issue if it has not been persisted

parent d967b122
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -4,7 +4,7 @@ v 8.7.0 (unreleased)
- Make HTTP(s) label consistent on clone bar (Stan Hu)
 
v 8.6.1 (unreleased)
- Do not allow to move issue if it has not been persisted
 
v 8.6.0
- Add ability to move issue to another project
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -85,7 +85,7 @@
- if can? current_user, :admin_label, issuable.project
= link_to 'Create new label', new_namespace_project_label_path(issuable.project.namespace, issuable.project), target: :blank
 
- if issuable.can_move?(current_user) && issuable.persisted?
- if issuable.can_move?(current_user)
%hr
.form-group
= label_tag :move_to_project_id, 'Move', class: 'control-label'
Loading
Loading
Loading
Loading
@@ -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) }
Loading
Loading
Loading
Loading
@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment