Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
915bfedf
Commit
915bfedf
authored
Mar 23, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not allow to move issue if it has not been persisted
parent
d967b122
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
3 deletions
+17
-3
CHANGELOG
CHANGELOG
+1
-1
app/models/issue.rb
app/models/issue.rb
+2
-1
app/services/issues/move_service.rb
app/services/issues/move_service.rb
+2
-0
app/views/shared/issuable/_form.html.haml
app/views/shared/issuable/_form.html.haml
+1
-1
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+5
-0
spec/services/issues/move_service_spec.rb
spec/services/issues/move_service_spec.rb
+6
-0
No files found.
CHANGELOG
View file @
915bfedf
...
@@ -4,7 +4,7 @@ v 8.7.0 (unreleased)
...
@@ -4,7 +4,7 @@ v 8.7.0 (unreleased)
- Make HTTP(s) label consistent on clone bar (Stan Hu)
- Make HTTP(s) label consistent on clone bar (Stan Hu)
v 8.6.1 (unreleased)
v 8.6.1 (unreleased)
- Do not allow to move issue if it has not been persisted
v 8.6.0
v 8.6.0
- Add ability to move issue to another project
- Add ability to move issue to another project
...
...
app/models/issue.rb
View file @
915bfedf
...
@@ -146,7 +146,8 @@ class Issue < ActiveRecord::Base
...
@@ -146,7 +146,8 @@ class Issue < ActiveRecord::Base
return
false
unless
user
.
can?
(:
admin_issue
,
to_project
)
return
false
unless
user
.
can?
(:
admin_issue
,
to_project
)
end
end
!
moved?
&&
user
.
can?
(
:admin_issue
,
self
.
project
)
!
moved?
&&
persisted?
&&
user
.
can?
(
:admin_issue
,
self
.
project
)
end
end
def
to_branch_name
def
to_branch_name
...
...
app/services/issues/move_service.rb
View file @
915bfedf
...
@@ -78,6 +78,8 @@ module Issues
...
@@ -78,6 +78,8 @@ module Issues
end
end
def
unfold_references
(
content
)
def
unfold_references
(
content
)
return
unless
content
rewriter
=
Gitlab
::
Gfm
::
ReferenceRewriter
.
new
(
content
,
@old_project
,
rewriter
=
Gitlab
::
Gfm
::
ReferenceRewriter
.
new
(
content
,
@old_project
,
@current_user
)
@current_user
)
rewriter
.
rewrite
(
@new_project
)
rewriter
.
rewrite
(
@new_project
)
...
...
app/views/shared/issuable/_form.html.haml
View file @
915bfedf
...
@@ -85,7 +85,7 @@
...
@@ -85,7 +85,7 @@
-
if
can?
current_user
,
:admin_label
,
issuable
.
project
-
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
=
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
%hr
.form-group
.form-group
=
label_tag
:move_to_project_id
,
'Move'
,
class:
'control-label'
=
label_tag
:move_to_project_id
,
'Move'
,
class:
'control-label'
...
...
spec/models/issue_spec.rb
View file @
915bfedf
...
@@ -152,6 +152,11 @@ describe Issue, models: true do
...
@@ -152,6 +152,11 @@ describe Issue, models: true do
it
{
is_expected
.
to
eq
true
}
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
context
'checking destination project also'
do
subject
{
issue
.
can_move?
(
user
,
to_project
)
}
subject
{
issue
.
can_move?
(
user
,
to_project
)
}
let
(
:to_project
)
{
create
(
:project
)
}
let
(
:to_project
)
{
create
(
:project
)
}
...
...
spec/services/issues/move_service_spec.rb
View file @
915bfedf
...
@@ -208,6 +208,12 @@ describe Issues::MoveService, services: true do
...
@@ -208,6 +208,12 @@ describe Issues::MoveService, services: true do
it
{
expect
{
move
}.
to
raise_error
(
StandardError
,
/permissions/
)
}
it
{
expect
{
move
}.
to
raise_error
(
StandardError
,
/permissions/
)
}
end
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
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment