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
4089be8f
Commit
4089be8f
authored
Feb 12, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
woo hoo - getting there with the cross-reference issue. Should fix the problem and updated spec
parent
a5b011c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
8 deletions
+17
-8
app/services/system_note_service.rb
app/services/system_note_service.rb
+11
-4
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+6
-4
No files found.
app/services/system_note_service.rb
View file @
4089be8f
...
...
@@ -280,6 +280,7 @@ class SystemNoteService
# mentioner - Mentionable object
#
# Returns Boolean
def
self
.
cross_reference_exists?
(
noteable
,
mentioner
)
# Initial scope should be system notes of this noteable type
notes
=
Note
.
system
.
where
(
noteable_type:
noteable
.
class
)
...
...
@@ -291,14 +292,20 @@ class SystemNoteService
notes
=
notes
.
where
(
noteable_id:
noteable
.
id
)
end
gfm_reference
=
mentioner
.
gfm_reference
(
nil
)
notes
=
notes
.
where
(
'note LIKE ?'
,
"
#{
cross_reference_note_prefix
}
%
#{
gfm_reference
}
"
)
notes
.
count
>
0
notes_for_mentioner
(
mentioner
,
noteable
,
notes
).
count
>
0
end
private
def
self
.
notes_for_mentioner
(
mentioner
,
noteable
,
notes
)
if
mentioner
.
is_a?
(
Commit
)
notes
.
where
(
'note LIKE ?'
,
"
#{
cross_reference_note_prefix
}
%
#{
mentioner
.
to_reference
(
nil
)
}
"
)
else
gfm_reference
=
mentioner
.
gfm_reference
(
noteable
.
project
)
notes
.
where
(
note:
cross_reference_note_content
(
gfm_reference
))
end
end
def
self
.
create_note
(
args
=
{})
Note
.
create
(
args
.
merge
(
system:
true
))
end
...
...
spec/services/system_note_service_spec.rb
View file @
4089be8f
...
...
@@ -425,18 +425,20 @@ describe SystemNoteService, services: true do
end
end
context
'commit from fork'
do
context
'commit
with cross-reference
from fork'
do
let
(
:author2
)
{
create
(
:user
)
}
let
(
:forked_project
)
{
Projects
::
ForkService
.
new
(
project
,
author2
).
execute
}
let
(
:commit2
)
{
forked_project
.
commit
}
before
do
described_class
.
cross_reference
(
noteable
,
commit2
,
author2
)
allow
(
commit0
).
to
receive
(
:to_reference
)
{
noteable
.
project
.
to_reference
+
commit0
.
class
.
reference_prefix
+
commit0
.
id
}
described_class
.
cross_reference
(
noteable
,
commit0
,
author2
)
end
it
'is
falsey when is a fork mentioning
an external issue'
do
it
'is
true when a fork mentions
an external issue'
do
expect
(
described_class
.
cross_reference_exists?
(
noteable
,
commit2
)).
to
be
_falsey
to
be
true
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