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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
6205e9d5
Commit
6205e9d5
authored
Dec 20, 2017
by
Jarka Kadlecová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use relation_path instead of destroy_relation_path
parent
05eacd01
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
22 deletions
+19
-22
ee/app/services/epic_issues/list_service.rb
ee/app/services/epic_issues/list_service.rb
+0
-4
ee/app/services/issuable_links/list_service.rb
ee/app/services/issuable_links/list_service.rb
+2
-1
ee/app/services/issue_links/list_service.rb
ee/app/services/issue_links/list_service.rb
+11
-11
spec/ee/spec/services/issue_links/list_service_spec.rb
spec/ee/spec/services/issue_links/list_service_spec.rb
+6
-6
No files found.
ee/app/services/epic_issues/list_service.rb
View file @
6205e9d5
...
...
@@ -21,9 +21,5 @@ module EpicIssues
def
reference
(
issue
)
issue
.
to_reference
(
full:
true
)
end
def
to_hash
(
issue
)
super
.
merge
(
relation_path:
relation_path
(
issue
))
end
end
end
ee/app/services/issuable_links/list_service.rb
View file @
6205e9d5
...
...
@@ -26,7 +26,8 @@ module IssuableLinks
title:
issue
.
title
,
state:
issue
.
state
,
reference:
reference
(
issue
),
path:
project_issue_path
(
issue
.
project
,
issue
.
iid
)
path:
project_issue_path
(
issue
.
project
,
issue
.
iid
),
relation_path:
relation_path
(
issue
)
}
end
end
...
...
ee/app/services/issue_links/list_service.rb
View file @
6205e9d5
module
IssueLinks
class
ListService
<
IssuableLinks
::
ListService
include
Gitlab
::
Utils
::
StrongMemoize
private
def
issues
issuable
.
related_issues
(
current_user
,
preload:
{
project: :namespace
})
end
def
destroy_relation_path
(
issue
)
current_project
=
issuable
.
project
def
relation_path
(
issue
)
# Make sure the user can admin both the current issue AND the
# referenced issue projects in order to return the removal link.
if
can_
destroy_issue_link_on_current_project?
(
current_project
)
&&
can_destroy
_issue_link?
(
issue
.
project
)
if
can_
admin_issue_link_on_current_project?
&&
can_admin
_issue_link?
(
issue
.
project
)
project_issue_link_path
(
current_project
,
issuable
.
iid
,
issue
.
issue_link_id
)
end
end
def
can_
destroy_issue_link_on_current_project?
(
current_project
)
return
@can_destroy_on_current_project
if
defined?
(
@can_destroy_on_current_project
)
@can_destroy_on_current_project
=
can_destroy_issue_link?
(
current_project
)
def
can_
admin_issue_link_on_current_project?
strong_memoize
(
:can_admin_on_current_project
)
do
can_admin_issue_link?
(
current_project
)
end
end
def
can_
destroy
_issue_link?
(
project
)
def
can_
admin
_issue_link?
(
project
)
Ability
.
allowed?
(
current_user
,
:admin_issue_link
,
project
)
end
def
to_hash
(
issue
)
super
.
merge
(
destroy_relation_path:
destroy_relation_path
(
issue
))
def
current_project
issuable
.
project
end
end
end
spec/ee/spec/services/issue_links/list_service_spec.rb
View file @
6205e9d5
...
...
@@ -57,21 +57,21 @@ describe IssueLinks::ListService do
state:
issue_b
.
state
,
reference:
issue_b
.
to_reference
(
project
),
path:
"/
#{
project
.
full_path
}
/issues/
#{
issue_b
.
iid
}
"
,
destroy_
relation_path:
"/
#{
project
.
full_path
}
/issues/
#{
issue
.
iid
}
/links/
#{
issue_link_a
.
id
}
"
))
relation_path:
"/
#{
project
.
full_path
}
/issues/
#{
issue
.
iid
}
/links/
#{
issue_link_a
.
id
}
"
))
expect
(
subject
).
to
include
(
include
(
id:
issue_c
.
id
,
title:
issue_c
.
title
,
state:
issue_c
.
state
,
reference:
issue_c
.
to_reference
(
project
),
path:
"/
#{
project
.
full_path
}
/issues/
#{
issue_c
.
iid
}
"
,
destroy_
relation_path:
"/
#{
project
.
full_path
}
/issues/
#{
issue
.
iid
}
/links/
#{
issue_link_b
.
id
}
"
))
relation_path:
"/
#{
project
.
full_path
}
/issues/
#{
issue
.
iid
}
/links/
#{
issue_link_b
.
id
}
"
))
expect
(
subject
).
to
include
(
include
(
id:
issue_d
.
id
,
title:
issue_d
.
title
,
state:
issue_d
.
state
,
reference:
issue_d
.
to_reference
(
project
),
path:
"/
#{
project
.
full_path
}
/issues/
#{
issue_d
.
iid
}
"
,
destroy_
relation_path:
"/
#{
project
.
full_path
}
/issues/
#{
issue
.
iid
}
/links/
#{
issue_link_c
.
id
}
"
))
relation_path:
"/
#{
project
.
full_path
}
/issues/
#{
issue
.
iid
}
/links/
#{
issue_link_c
.
id
}
"
))
end
end
...
...
@@ -164,7 +164,7 @@ describe IssueLinks::ListService do
it
'returns no destroy relation path'
do
target_project
.
add_developer
(
user
)
expect
(
subject
.
first
[
:
destroy_
relation_path
]).
to
be_nil
expect
(
subject
.
first
[
:relation_path
]).
to
be_nil
end
end
...
...
@@ -176,7 +176,7 @@ describe IssueLinks::ListService do
it
'returns no destroy relation path'
do
target_project
.
add_guest
(
user
)
expect
(
subject
.
first
[
:
destroy_
relation_path
]).
to
be_nil
expect
(
subject
.
first
[
:relation_path
]).
to
be_nil
end
end
...
...
@@ -184,7 +184,7 @@ describe IssueLinks::ListService do
let
(
:referenced_issue
)
{
create
:issue
,
project:
project
}
it
'returns related issue destroy relation path'
do
expect
(
subject
.
first
[
:
destroy_
relation_path
])
expect
(
subject
.
first
[
:relation_path
])
.
to
eq
(
"/
#{
project
.
full_path
}
/issues/
#{
issue
.
iid
}
/links/
#{
issue_link
.
id
}
"
)
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