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
aff9dadf
Commit
aff9dadf
authored
Jun 13, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bug/jira_issue_closing' into 'master'
Fix JIRA issue closing bug
parents
2b9a9d4c
e496b147
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
91 additions
and
3 deletions
+91
-3
CHANGELOG-EE
CHANGELOG-EE
+3
-0
app/helpers/merge_requests_helper.rb
app/helpers/merge_requests_helper.rb
+4
-0
app/models/jira_issue.rb
app/models/jira_issue.rb
+21
-0
app/views/projects/merge_requests/show/_state_widget.html.haml
...iews/projects/merge_requests/show/_state_widget.html.haml
+1
-1
lib/gitlab/reference_extractor.rb
lib/gitlab/reference_extractor.rb
+3
-1
spec/helpers/merge_requests_helper.rb
spec/helpers/merge_requests_helper.rb
+20
-0
spec/lib/gitlab/reference_extractor_spec.rb
spec/lib/gitlab/reference_extractor_spec.rb
+9
-0
spec/models/jira_issue_spec.rb
spec/models/jira_issue_spec.rb
+18
-0
spec/models/jira_service_spec.rb
spec/models/jira_service_spec.rb
+1
-1
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+11
-0
No files found.
CHANGELOG-EE
View file @
aff9dadf
v 7.0.0
- Fix bug in JIRA Issue closing triggered by commit messages
v 6.9.3
- Fix check CI status only when CI service is enabled(Daniel Aquino)
...
...
app/helpers/merge_requests_helper.rb
View file @
aff9dadf
...
...
@@ -42,4 +42,8 @@ module MergeRequestsHelper
"Branches:
#{
@merge_request
.
source_branch
}
#{
separator
}
#{
@merge_request
.
target_branch
}
"
end
end
def
issues_sentence
(
issues
)
issues
.
map
{
|
i
|
"#
#{
i
.
iid
}
"
}.
to_sentence
end
end
app/models/jira_issue.rb
0 → 100644
View file @
aff9dadf
class
JiraIssue
def
initialize
(
issue_identifier
)
@issue_identifier
=
issue_identifier
end
def
to_s
@issue_identifier
.
to_s
end
def
id
@issue_identifier
.
to_s
end
def
iid
@issue_identifier
.
to_s
end
def
==
(
other
)
other
.
is_a?
(
self
.
class
)
&&
(
to_s
==
other
.
to_s
)
end
end
app/views/projects/merge_requests/show/_state_widget.html.haml
View file @
aff9dadf
...
...
@@ -37,5 +37,5 @@
%i
.icon-ok
Accepting this merge request will close
#{
@closes_issues
.
size
==
1
?
'issue'
:
'issues'
}
=
succeed
'.'
do
!=
gfm
(
@closes_issues
.
map
{
|
i
|
"#
#{
i
.
iid
}
"
}.
to_sentence
)
!=
gfm
(
issues_sentence
(
@closes_issues
)
)
lib/gitlab/reference_extractor.rb
View file @
aff9dadf
...
...
@@ -24,7 +24,9 @@ module Gitlab
def
issues_for
project
if
project
.
jira_tracker?
issues
.
uniq
issues
.
uniq
.
map
do
|
jira_identifier
|
JiraIssue
.
new
(
jira_identifier
)
end
else
issues
.
map
do
|
identifier
|
project
.
issues
.
where
(
iid:
identifier
).
first
...
...
spec/helpers/merge_requests_helper.rb
0 → 100644
View file @
aff9dadf
require
'spec_helper'
describe
MergeRequestsHelper
do
describe
:issues_sentence
do
subject
{
issues_sentence
(
issues
)
}
let
(
:issues
)
do
[
build
(
:issue
,
iid:
1
),
build
(
:issue
,
iid:
2
),
build
(
:issue
,
iid:
3
)]
end
it
{
should
eq
(
'#1, #2, and #3'
)
}
context
'for JIRA issues'
do
let
(
:issues
)
do
[
JiraIssue
.
new
(
'JIRA-123'
),
JiraIssue
.
new
(
'JIRA-456'
),
JiraIssue
.
new
(
'FOOBAR-7890'
)]
end
it
{
should
eq
(
'#JIRA-123, #JIRA-456, and #FOOBAR-7890'
)
}
end
end
end
spec/lib/gitlab/reference_extractor_spec.rb
View file @
aff9dadf
...
...
@@ -71,6 +71,15 @@ describe Gitlab::ReferenceExtractor do
subject
.
issues_for
(
project
).
should
==
[
@i0
,
@i1
]
end
it
'returns JIRA issues for a JIRA-integrated project'
do
project
.
stub
(
jira_tracker?:
true
)
subject
.
analyze
(
'JIRA-123 and FOOBAR-4567'
)
subject
.
issues_for
(
project
).
should
eq
(
[
JiraIssue
.
new
(
'JIRA-123'
),
JiraIssue
.
new
(
'FOOBAR-4567'
)]
)
end
it
'accesses valid merge requests'
do
@m0
=
create
(
:merge_request
,
source_project:
project
,
target_project:
project
,
source_branch:
'aaa'
)
@m1
=
create
(
:merge_request
,
source_project:
project
,
target_project:
project
,
source_branch:
'bbb'
)
...
...
spec/models/jira_issue_spec.rb
0 → 100644
View file @
aff9dadf
require
'spec_helper'
describe
JiraIssue
do
subject
{
JiraIssue
.
new
(
'JIRA-123'
)
}
its
(
:id
)
{
should
eq
(
'JIRA-123'
)
}
its
(
:iid
)
{
should
eq
(
'JIRA-123'
)
}
its
(
:to_s
)
{
should
eq
(
'JIRA-123'
)
}
describe
:==
do
specify
{
subject
.
should
eq
(
JiraIssue
.
new
(
'JIRA-123'
))
}
specify
{
subject
.
should_not
eq
(
JiraIssue
.
new
(
'JIRA-124'
))
}
it
'only compares with JiraIssues'
do
subject
.
should_not
eq
(
'JIRA-123'
)
end
end
end
spec/models/jira_service_spec.rb
View file @
aff9dadf
...
...
@@ -50,7 +50,7 @@ describe JiraService, models: true do
end
it
"should call JIRA API"
do
@jira_service
.
execute
(
@sample_data
,
"JIRA-123"
)
@jira_service
.
execute
(
@sample_data
,
JiraIssue
.
new
(
"JIRA-123"
)
)
WebMock
.
should
have_requested
(
:post
,
@api_url
).
with
(
body:
/Issue solved with/
).
once
...
...
spec/models/merge_request_spec.rb
View file @
aff9dadf
...
...
@@ -124,6 +124,17 @@ describe MergeRequest do
subject
.
closes_issues
.
should
be_empty
end
context
'for a project with JIRA integration'
do
let
(
:issue0
)
{
JiraIssue
.
new
(
'JIRA-123'
)
}
let
(
:issue1
)
{
JiraIssue
.
new
(
'FOOBAR-4567'
)
}
it
'returns sorted JiraIssues'
do
subject
.
project
.
stub
(
default_branch:
subject
.
target_branch
)
subject
.
closes_issues
.
should
eq
([
issue1
,
issue0
])
end
end
end
it_behaves_like
'an editable mentionable'
do
...
...
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