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
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
Show 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
...
@@ -28,13 +28,13 @@ module Banzai
issue_parser
=
Banzai
::
ReferenceParser
::
IssueParser
.
new
(
project
,
user
)
issue_parser
=
Banzai
::
ReferenceParser
::
IssueParser
.
new
(
project
,
user
)
merge_request_parser
=
Banzai
::
ReferenceParser
::
MergeRequestParser
.
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
)
merge_request_parser
.
merge_requests_for_nodes
(
nodes
)
)
)
hash
.
each_with_object
({})
do
|
(
node
,
issuable
),
result
|
# The project for the issue might be pending for deletion!
result
[
node
]
=
issuable
if
issuable
.
project
# Filter them out because we don't care about them.
end
issues_for_nodes
.
select
{
|
node
,
issuable
|
issuable
.
project
}
end
end
end
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
...
@@ -6,23 +6,19 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:context
)
{
{
current_user:
user
,
issuable_state_filter_enabled:
true
}
}
let
(
:context
)
{
{
current_user:
user
,
issuable_state_filter_enabled:
true
}
}
let
(
:closed_issue
)
{
create_issue
(
:closed
,
project
)
}
let
(
:closed_issue
)
{
create_issue
(
:closed
)
}
let
(
:project
)
{
create
_project
}
let
(
:project
)
{
create
(
:empty_project
,
:public
)
}
let
(
:other_project
)
{
create
_project
}
let
(
:other_project
)
{
create
(
:empty_project
,
:public
)
}
def
create_link
(
text
,
data
)
def
create_link
(
text
,
data
)
link_to
(
text
,
''
,
class:
'gfm has-tooltip'
,
data:
data
)
link_to
(
text
,
''
,
class:
'gfm has-tooltip'
,
data:
data
)
end
end
def
create_
project
def
create_
issue
(
state
)
create
(
:
empty_project
,
:public
)
create
(
:
issue
,
state
,
project:
project
)
end
end
def
create_issue
(
state
,
the_project
=
project
)
def
create_merge_request
(
state
)
create
(
:issue
,
state
,
project:
the_project
)
end
def
create_merge_request
(
state
,
the_project
=
project
)
create
(
:merge_request
,
state
,
create
(
:merge_request
,
state
,
source_project:
project
,
target_project:
project
)
source_project:
project
,
target_project:
project
)
end
end
...
@@ -91,7 +87,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
...
@@ -91,7 +87,7 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
context
'when project is in pending delete'
do
context
'when project is in pending delete'
do
before
do
before
do
project
.
update
(
pending_delete:
true
)
project
.
update
!
(
pending_delete:
true
)
end
end
it
'does not append issue state'
do
it
'does not append issue state'
do
...
@@ -128,7 +124,9 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
...
@@ -128,7 +124,9 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
end
end
context
'for merge request references'
do
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
(
link
=
create_link
(
merge_request
.
to_reference
,
merge_request
.
to_reference
,
merge_request:
merge_request
.
id
,
merge_request:
merge_request
.
id
,
...
@@ -137,37 +135,63 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
...
@@ -137,37 +135,63 @@ describe Banzai::Filter::IssuableStateFilter, lib: true do
doc
=
filter
(
link
,
context
)
doc
=
filter
(
link
,
context
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
text
)
expect
(
doc
.
css
(
'a'
).
last
.
text
).
to
eq
(
merge_request
.
to_reference
)
end
it
'ignores open merge request references'
do
merge_request
=
create_merge_request
(
:opened
)
expect_link_text
(
merge_request
,
merge_request
.
to_reference
)
end
end
it
'ignores reopened merge request references'
do
it
'ignores reopened merge request references'
do
merge_request
=
create_merge_request
(
:reopened
)
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
end
it
'ignores locked merge request references'
do
it
'ignores locked merge request references'
do
merge_request
=
create_merge_request
(
:locked
)
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
end
it
'appends state to closed merge request references'
do
it
'appends state to closed merge request references'
do
merge_request
=
create_merge_request
(
:closed
)
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
end
it
'appends state to merged merge request references'
do
it
'appends state to merged merge request references'
do
merge_request
=
create_merge_request
(
:merged
)
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
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