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
Jérome Perrin
gitlab-ce
Commits
9f7c29ba
Commit
9f7c29ba
authored
Apr 26, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Follow feedback on the review
parent
4ded8b1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
27 deletions
+51
-27
lib/banzai/issuable_extractor.rb
lib/banzai/issuable_extractor.rb
+4
-4
spec/lib/banzai/filter/issuable_state_filter_spec.rb
spec/lib/banzai/filter/issuable_state_filter_spec.rb
+47
-23
No files found.
lib/banzai/issuable_extractor.rb
View file @
9f7c29ba
...
...
@@ -28,13 +28,13 @@ module Banzai
issue_parser
=
Banzai
::
ReferenceParser
::
IssueParser
.
new
(
project
,
user
)
merge_request_parser
=
Banzai
::
ReferenceParser
::
MergeRequestParser
.
new
(
project
,
user
)
hash
=
issue_parser
.
issues_for_nodes
(
nodes
).
merge
(
issues_for_nodes
=
issue_parser
.
issues_for_nodes
(
nodes
).
merge
(
merge_request_parser
.
merge_requests_for_nodes
(
nodes
)
)
hash
.
each_with_object
({})
do
|
(
node
,
issuable
),
result
|
result
[
node
]
=
issuable
if
issuable
.
project
end
# The project for the issue might be pending for deletion!
# Filter them out because we don't care about them.
issues_for_nodes
.
select
{
|
node
,
issuable
|
issuable
.
project
}
end
end
end
spec/lib/banzai/filter/issuable_state_filter_spec.rb
View file @
9f7c29ba
...
...
@@ -6,23 +6,19 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
let
(
:user
)
{
create
(
:user
)
}
let
(
:context
)
{
{
current_user:
user
,
issuable_state_filter_enabled:
true
}
}
let
(
:closed_issue
)
{
create_issue
(
:closed
,
project
)
}
let
(
:project
)
{
create
_project
}
let
(
:other_project
)
{
create
_project
}
let
(
:closed_issue
)
{
create_issue
(
:closed
)
}
let
(
:project
)
{
create
(
:empty_project
,
:public
)
}
let
(
:other_project
)
{
create
(
:empty_project
,
:public
)
}
def
create_link
(
text
,
data
)
link_to
(
text
,
''
,
class:
'gfm has-tooltip'
,
data:
data
)
end
def
create_
project
create
(
:
empty_project
,
:public
)
def
create_
issue
(
state
)
create
(
:
issue
,
state
,
project:
project
)
end
def
create_issue
(
state
,
the_project
=
project
)
create
(
:issue
,
state
,
project:
the_project
)
end
def
create_merge_request
(
state
,
the_project
=
project
)
def
create_merge_request
(
state
)
create
(
:merge_request
,
state
,
source_project:
project
,
target_project:
project
)
end
...
...
@@ -91,7 +87,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
context
'when project is in pending delete'
do
before
do
project
.
update
(
pending_delete:
true
)
project
.
update
!
(
pending_delete:
true
)
end
it
'does not append issue state'
do
...
...
@@ -128,7 +124,9 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
end
context
'for merge request references'
do
def
expect_link_text
(
merge_request
,
text
)
it
'ignores open merge request references'
do
merge_request
=
create_merge_request
(
:opened
)
link
=
create_link
(
merge_request
.
to_reference
,
merge_request:
merge_request
.
id
,
...
...
@@ -137,37 +135,63 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
text
)
end
it
'ignores open merge request references'
do
merge_request
=
create_merge_request
(
:opened
)
expect_link_text
(
merge_request
,
merge_request
.
to_reference
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
merge_request
.
to_reference
)
end
it
'ignores reopened merge request references'
do
merge_request
=
create_merge_request
(
:reopened
)
expect_link_text
(
merge_request
,
merge_request
.
to_reference
)
link
=
create_link
(
merge_request
.
to_reference
,
merge_request:
merge_request
.
id
,
reference_type:
'merge_request'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
merge_request
.
to_reference
)
end
it
'ignores locked merge request references'
do
merge_request
=
create_merge_request
(
:locked
)
expect_link_text
(
merge_request
,
merge_request
.
to_reference
)
link
=
create_link
(
merge_request
.
to_reference
,
merge_request:
merge_request
.
id
,
reference_type:
'merge_request'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
merge_request
.
to_reference
)
end
it
'appends state to closed merge request references'
do
merge_request
=
create_merge_request
(
:closed
)
expect_link_text
(
merge_request
,
"
#{
merge_request
.
to_reference
}
(closed)"
)
link
=
create_link
(
merge_request
.
to_reference
,
merge_request:
merge_request
.
id
,
reference_type:
'merge_request'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
"
#{
merge_request
.
to_reference
}
(closed)"
)
end
it
'appends state to merged merge request references'
do
merge_request
=
create_merge_request
(
:merged
)
expect_link_text
(
merge_request
,
"
#{
merge_request
.
to_reference
}
(merged)"
)
link
=
create_link
(
merge_request
.
to_reference
,
merge_request:
merge_request
.
id
,
reference_type:
'merge_request'
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
"
#{
merge_request
.
to_reference
}
(merged)"
)
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