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
Tatuya Kamada
gitlab-ce
Commits
4a0ebccf
Commit
4a0ebccf
authored
Nov 30, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs
parent
bf5e7252
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
26 deletions
+22
-26
app/models/concerns/mentionable.rb
app/models/concerns/mentionable.rb
+8
-3
spec/lib/gitlab/markdown/commit_reference_filter_spec.rb
spec/lib/gitlab/markdown/commit_reference_filter_spec.rb
+0
-1
spec/lib/gitlab/markdown/merge_request_reference_filter_spec.rb
...ib/gitlab/markdown/merge_request_reference_filter_spec.rb
+1
-2
spec/models/commit_spec.rb
spec/models/commit_spec.rb
+6
-10
spec/support/mentionable_shared_examples.rb
spec/support/mentionable_shared_examples.rb
+7
-10
No files found.
app/models/concerns/mentionable.rb
View file @
4a0ebccf
...
@@ -62,7 +62,12 @@ module Mentionable
...
@@ -62,7 +62,12 @@ module Mentionable
return
[]
if
text
.
blank?
return
[]
if
text
.
blank?
refs
=
all_references
(
current_user
,
text
,
load_lazy_references:
load_lazy_references
)
refs
=
all_references
(
current_user
,
text
,
load_lazy_references:
load_lazy_references
)
(
refs
.
issues
+
refs
.
merge_requests
+
refs
.
commits
)
-
[
local_reference
]
refs
=
(
refs
.
issues
+
refs
.
merge_requests
+
refs
.
commits
)
# We're using this method instead of Array diffing because that requires
# both of the object's `hash` values to be the same, which may not be the
# case for otherwise identical Commit objects.
refs
.
reject!
{
|
ref
|
ref
==
local_reference
}
end
end
# Create a cross-reference Note for each GFM reference to another Mentionable found in +mentionable_text+.
# Create a cross-reference Note for each GFM reference to another Mentionable found in +mentionable_text+.
...
...
spec/lib/gitlab/markdown/commit_reference_filter_spec.rb
View file @
4a0ebccf
...
@@ -148,7 +148,6 @@ module Gitlab::Markdown
...
@@ -148,7 +148,6 @@ module Gitlab::Markdown
it
'links with adjacent text'
do
it
'links with adjacent text'
do
doc
=
filter
(
"Fixed (
#{
reference
}
.)"
)
doc
=
filter
(
"Fixed (
#{
reference
}
.)"
)
exp
=
Regexp
.
escape
(
project2
.
to_reference
)
expect
(
doc
.
to_html
).
to
match
(
/\(<a.+>
#{
commit
.
to_reference
(
project
)
}
<\/a>\.\)/
)
expect
(
doc
.
to_html
).
to
match
(
/\(<a.+>
#{
commit
.
to_reference
(
project
)
}
<\/a>\.\)/
)
end
end
...
...
spec/lib/gitlab/markdown/merge_request_reference_filter_spec.rb
View file @
4a0ebccf
...
@@ -121,8 +121,7 @@ module Gitlab::Markdown
...
@@ -121,8 +121,7 @@ module Gitlab::Markdown
let
(
:namespace
)
{
create
(
:namespace
,
name:
'cross-reference'
)
}
let
(
:namespace
)
{
create
(
:namespace
,
name:
'cross-reference'
)
}
let
(
:project2
)
{
create
(
:project
,
:public
,
namespace:
namespace
)
}
let
(
:project2
)
{
create
(
:project
,
:public
,
namespace:
namespace
)
}
let
(
:merge
)
{
create
(
:merge_request
,
source_project:
project2
,
target_project:
project2
)
}
let
(
:merge
)
{
create
(
:merge_request
,
source_project:
project2
,
target_project:
project2
)
}
let
(
:reference
)
{
urls
.
namespace_project_merge_request_url
(
project2
.
namespace
,
let
(
:reference
)
{
urls
.
namespace_project_merge_request_url
(
project2
.
namespace
,
project2
,
merge
)
+
'/diffs#note_123'
}
project2
,
merge
)
+
'/diffs#note_123'
}
it
'links to a valid reference'
do
it
'links to a valid reference'
do
doc
=
filter
(
"See
#{
reference
}
"
)
doc
=
filter
(
"See
#{
reference
}
"
)
...
...
spec/models/commit_spec.rb
View file @
4a0ebccf
...
@@ -15,12 +15,12 @@ describe Commit do
...
@@ -15,12 +15,12 @@ describe Commit do
describe
'#to_reference'
do
describe
'#to_reference'
do
it
'returns a String reference to the object'
do
it
'returns a String reference to the object'
do
expect
(
commit
.
to_reference
).
to
eq
commit
.
id
expect
(
commit
.
to_reference
).
to
eq
commit
.
short_
id
end
end
it
'supports a cross-project reference'
do
it
'supports a cross-project reference'
do
cross
=
double
(
'project'
)
cross
=
double
(
'project'
)
expect
(
commit
.
to_reference
(
cross
)).
to
eq
"
#{
project
.
to_reference
}
@
#{
commit
.
id
}
"
expect
(
commit
.
to_reference
(
cross
)).
to
eq
"
#{
project
.
to_reference
}
@
#{
commit
.
short_
id
}
"
end
end
end
end
...
@@ -77,14 +77,10 @@ eos
...
@@ -77,14 +77,10 @@ eos
let
(
:other_issue
)
{
create
:issue
,
project:
other_project
}
let
(
:other_issue
)
{
create
:issue
,
project:
other_project
}
it
'detects issues that this commit is marked as closing'
do
it
'detects issues that this commit is marked as closing'
do
allow
(
commit
).
to
receive
(
:safe_message
).
and_return
(
"Fixes #
#{
issue
.
iid
}
"
)
expect
(
commit
.
closes_issues
).
to
eq
([
issue
])
end
it
'does not detect issues from other projects'
do
ext_ref
=
"
#{
other_project
.
path_with_namespace
}
#
#{
other_issue
.
iid
}
"
ext_ref
=
"
#{
other_project
.
path_with_namespace
}
#
#{
other_issue
.
iid
}
"
allow
(
commit
).
to
receive
(
:safe_message
).
and_return
(
"Fixes
#{
ext_ref
}
"
)
allow
(
commit
).
to
receive
(
:safe_message
).
and_return
(
"Fixes #
#{
issue
.
iid
}
and
#{
ext_ref
}
"
)
expect
(
commit
.
closes_issues
).
to
be_empty
expect
(
commit
.
closes_issues
).
to
include
(
issue
)
expect
(
commit
.
closes_issues
).
to
include
(
other_issue
)
end
end
end
end
...
@@ -92,7 +88,7 @@ eos
...
@@ -92,7 +88,7 @@ eos
subject
{
create
(
:project
).
commit
}
subject
{
create
(
:project
).
commit
}
let
(
:author
)
{
create
(
:user
,
email:
subject
.
author_email
)
}
let
(
:author
)
{
create
(
:user
,
email:
subject
.
author_email
)
}
let
(
:backref_text
)
{
"commit
#{
subject
.
id
}
"
}
let
(
:backref_text
)
{
"commit
#{
subject
.
short_
id
}
"
}
let
(
:set_mentionable_text
)
do
let
(
:set_mentionable_text
)
do
->
(
txt
)
{
allow
(
subject
).
to
receive
(
:safe_message
).
and_return
(
txt
)
}
->
(
txt
)
{
allow
(
subject
).
to
receive
(
:safe_message
).
and_return
(
txt
)
}
end
end
...
...
spec/support/mentionable_shared_examples.rb
View file @
4a0ebccf
...
@@ -10,12 +10,12 @@ def common_mentionable_setup
...
@@ -10,12 +10,12 @@ def common_mentionable_setup
let
(
:mentioned_issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:mentioned_issue
)
{
create
(
:issue
,
project:
project
)
}
let!
(
:mentioned_mr
)
{
create
(
:merge_request
,
:simple
,
source_project:
project
)
}
let!
(
:mentioned_mr
)
{
create
(
:merge_request
,
:simple
,
source_project:
project
)
}
let
(
:mentioned_commit
)
{
project
.
commit
}
let
(
:mentioned_commit
)
{
project
.
commit
(
"HEAD~1"
)
}
let
(
:ext_proj
)
{
create
(
:project
,
:public
)
}
let
(
:ext_proj
)
{
create
(
:project
,
:public
)
}
let
(
:ext_issue
)
{
create
(
:issue
,
project:
ext_proj
)
}
let
(
:ext_issue
)
{
create
(
:issue
,
project:
ext_proj
)
}
let
(
:ext_mr
)
{
create
(
:merge_request
,
:simple
,
source_project:
ext_proj
)
}
let
(
:ext_mr
)
{
create
(
:merge_request
,
:simple
,
source_project:
ext_proj
)
}
let
(
:ext_commit
)
{
ext_proj
.
commit
}
let
(
:ext_commit
)
{
ext_proj
.
commit
(
"HEAD~2"
)
}
# Override to add known commits to the repository stub.
# Override to add known commits to the repository stub.
let
(
:extra_commits
)
{
[]
}
let
(
:extra_commits
)
{
[]
}
...
@@ -45,14 +45,11 @@ def common_mentionable_setup
...
@@ -45,14 +45,11 @@ def common_mentionable_setup
before
do
before
do
# Wire the project's repository to return the mentioned commit, and +nil+
# Wire the project's repository to return the mentioned commit, and +nil+
# for any unrecognized commits.
# for any unrecognized commits.
commitmap
=
{
allow_any_instance_of
(
::
Repository
).
to
receive
(
:commit
).
and_call_original
mentioned_commit
.
id
=>
mentioned_commit
allow_any_instance_of
(
::
Repository
).
to
receive
(
:commit
).
with
(
mentioned_commit
.
short_id
).
and_return
(
mentioned_commit
)
}
extra_commits
.
each
do
|
commit
|
extra_commits
.
each
{
|
c
|
commitmap
[
c
.
short_id
]
=
c
}
allow_any_instance_of
(
::
Repository
).
to
receive
(
:commit
).
with
(
commit
.
short_id
).
and_return
(
commit
)
end
allow
(
Project
).
to
receive
(
:find
).
and_call_original
allow
(
Project
).
to
receive
(
:find
).
with
(
project
.
id
.
to_s
).
and_return
(
project
)
allow
(
project
.
repository
).
to
receive
(
:commit
)
{
|
sha
|
commitmap
[
sha
]
}
set_mentionable_text
.
call
(
ref_string
)
set_mentionable_text
.
call
(
ref_string
)
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