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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
23954b0f
Commit
23954b0f
authored
Jun 08, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly remove already-mentioned commits for cross references
Fixes #1778
parent
b637f849
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
3 deletions
+26
-3
app/models/concerns/mentionable.rb
app/models/concerns/mentionable.rb
+7
-1
spec/models/concerns/mentionable_spec.rb
spec/models/concerns/mentionable_spec.rb
+19
-2
No files found.
app/models/concerns/mentionable.rb
View file @
23954b0f
...
...
@@ -67,7 +67,13 @@ module Mentionable
# Create a cross-reference Note for each GFM reference to another Mentionable found in +mentionable_text+.
def
create_cross_references!
(
p
=
project
,
a
=
author
,
without
=
[])
refs
=
references
(
p
)
-
without
refs
=
references
(
p
)
# 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
|
without
.
include?
(
ref
)
}
refs
.
each
do
|
ref
|
Note
.
create_cross_reference_note
(
ref
,
local_reference
,
a
)
end
...
...
spec/models/concerns/mentionable_spec.rb
View file @
23954b0f
require
'spec_helper'
describe
Issue
,
"Mentionable"
do
describe
:mentioned_users
do
describe
'#mentioned_users'
do
let!
(
:user
)
{
create
(
:user
,
username:
'stranger'
)
}
let!
(
:user2
)
{
create
(
:user
,
username:
'john'
)
}
let!
(
:issue
)
{
create
(
:issue
,
description:
'@stranger mentioned'
)
}
let!
(
:issue
)
{
create
(
:issue
,
description:
"
#{
user
.
to_reference
}
mentioned"
)
}
subject
{
issue
.
mentioned_users
}
it
{
is_expected
.
to
include
(
user
)
}
it
{
is_expected
.
not_to
include
(
user2
)
}
end
describe
'#create_cross_references!'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:author
)
{
double
(
'author'
)
}
let
(
:commit
)
{
project
.
commit
}
let
(
:commit2
)
{
project
.
commit
}
let!
(
:issue
)
do
create
(
:issue
,
project:
project
,
description:
commit
.
to_reference
)
end
it
'correctly removes already-mentioned Commits'
do
expect
(
Note
).
not_to
receive
(
:create_cross_reference_note
)
issue
.
create_cross_references!
(
project
,
author
,
[
commit2
])
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