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
03d199fb
Commit
03d199fb
authored
Aug 01, 2017
by
Mehdi Lahmam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure `JIRA::Resource::Issue` responds to `resolution` before calling it
parent
56046ca8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
app/models/project_services/jira_service.rb
app/models/project_services/jira_service.rb
+6
-2
spec/models/project_services/jira_service_spec.rb
spec/models/project_services/jira_service_spec.rb
+9
-0
No files found.
app/models/project_services/jira_service.rb
View file @
03d199fb
...
@@ -104,7 +104,7 @@ class JiraService < IssueTrackerService
...
@@ -104,7 +104,7 @@ class JiraService < IssueTrackerService
def
close_issue
(
entity
,
external_issue
)
def
close_issue
(
entity
,
external_issue
)
issue
=
jira_request
{
client
.
Issue
.
find
(
external_issue
.
iid
)
}
issue
=
jira_request
{
client
.
Issue
.
find
(
external_issue
.
iid
)
}
return
if
issue
.
nil?
||
issue
.
resolution
.
present?
||
!
jira_issue_transition_id
.
present?
return
if
issue
.
nil?
||
has_resolution?
(
issue
)
||
!
jira_issue_transition_id
.
present?
commit_id
=
if
entity
.
is_a?
(
Commit
)
commit_id
=
if
entity
.
is_a?
(
Commit
)
entity
.
id
entity
.
id
...
@@ -118,7 +118,7 @@ class JiraService < IssueTrackerService
...
@@ -118,7 +118,7 @@ class JiraService < IssueTrackerService
# may or may not be allowed. Refresh the issue after transition and check
# may or may not be allowed. Refresh the issue after transition and check
# if it is closed, so we don't have one comment for every commit.
# if it is closed, so we don't have one comment for every commit.
issue
=
jira_request
{
client
.
Issue
.
find
(
issue
.
key
)
}
if
transition_issue
(
issue
)
issue
=
jira_request
{
client
.
Issue
.
find
(
issue
.
key
)
}
if
transition_issue
(
issue
)
add_issue_solved_comment
(
issue
,
commit_id
,
commit_url
)
if
issue
.
resolution
add_issue_solved_comment
(
issue
,
commit_id
,
commit_url
)
if
has_resolution?
(
issue
)
end
end
def
create_cross_reference_note
(
mentioned
,
noteable
,
author
)
def
create_cross_reference_note
(
mentioned
,
noteable
,
author
)
...
@@ -216,6 +216,10 @@ class JiraService < IssueTrackerService
...
@@ -216,6 +216,10 @@ class JiraService < IssueTrackerService
end
end
end
end
def
has_resolution?
(
issue
)
issue
.
respond_to?
(
:resolution
)
&&
issue
.
resolution
.
present?
end
def
comment_exists?
(
issue
,
message
)
def
comment_exists?
(
issue
,
message
)
comments
=
jira_request
{
issue
.
comments
}
comments
=
jira_request
{
issue
.
comments
}
...
...
spec/models/project_services/jira_service_spec.rb
View file @
03d199fb
...
@@ -153,6 +153,15 @@ describe JiraService do
...
@@ -153,6 +153,15 @@ describe JiraService do
expect
(
WebMock
).
not_to
have_requested
(
:post
,
@remote_link_url
)
expect
(
WebMock
).
not_to
have_requested
(
:post
,
@remote_link_url
)
end
end
it
"does not send comment or remote links to issues with unknown resolution"
do
allow_any_instance_of
(
JIRA
::
Resource
::
Issue
).
to
receive
(
:respond_to?
).
with
(
:resolution
).
and_return
(
false
)
@jira_service
.
close_issue
(
merge_request
,
ExternalIssue
.
new
(
"JIRA-123"
,
project
))
expect
(
WebMock
).
not_to
have_requested
(
:post
,
@comment_url
)
expect
(
WebMock
).
not_to
have_requested
(
:post
,
@remote_link_url
)
end
it
"references the GitLab commit/merge request"
do
it
"references the GitLab commit/merge request"
do
stub_config_setting
(
base_url:
custom_base_url
)
stub_config_setting
(
base_url:
custom_base_url
)
...
...
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