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
Léo-Paul Géneau
gitlab-ce
Commits
f3d4767d
Commit
f3d4767d
authored
Jul 13, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename `notice_added_references` to `create_new_cross_references!`
parent
e4c698fd
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
12 deletions
+12
-12
app/models/concerns/mentionable.rb
app/models/concerns/mentionable.rb
+3
-3
app/models/note.rb
app/models/note.rb
+1
-1
app/services/issues/update_service.rb
app/services/issues/update_service.rb
+1
-1
app/services/merge_requests/update_service.rb
app/services/merge_requests/update_service.rb
+1
-1
spec/models/concerns/mentionable_spec.rb
spec/models/concerns/mentionable_spec.rb
+5
-5
spec/support/mentionable_shared_examples.rb
spec/support/mentionable_shared_examples.rb
+1
-1
No files found.
app/models/concerns/mentionable.rb
View file @
f3d4767d
...
@@ -79,9 +79,9 @@ module Mentionable
...
@@ -79,9 +79,9 @@ module Mentionable
end
end
end
end
#
If the mentionable_text field is about to change, locate any *added* references and create cross references for
#
When a mentionable field is changed, creates cross-reference notes that
#
them. Invoke from an observer's #before_save implementation.
#
don't already exist
def
notice_added_references
(
p
=
project
,
a
=
author
)
def
create_new_cross_references!
(
p
=
project
,
a
=
author
)
changes
=
detect_mentionable_changes
changes
=
detect_mentionable_changes
return
if
changes
.
empty?
return
if
changes
.
empty?
...
...
app/models/note.rb
View file @
f3d4767d
...
@@ -356,7 +356,7 @@ class Note < ActiveRecord::Base
...
@@ -356,7 +356,7 @@ class Note < ActiveRecord::Base
end
end
def
set_references
def
set_references
notice_added_references
(
project
,
author
)
create_new_cross_references!
(
project
,
author
)
end
end
def
editable?
def
editable?
...
...
app/services/issues/update_service.rb
View file @
f3d4767d
...
@@ -35,7 +35,7 @@ module Issues
...
@@ -35,7 +35,7 @@ module Issues
create_title_change_note
(
issue
,
issue
.
previous_changes
[
'title'
].
first
)
create_title_change_note
(
issue
,
issue
.
previous_changes
[
'title'
].
first
)
end
end
issue
.
notice_added_references
(
issue
.
project
,
current_user
)
issue
.
create_new_cross_references!
(
issue
.
project
,
current_user
)
execute_hooks
(
issue
,
'update'
)
execute_hooks
(
issue
,
'update'
)
end
end
...
...
app/services/merge_requests/update_service.rb
View file @
f3d4767d
...
@@ -59,7 +59,7 @@ module MergeRequests
...
@@ -59,7 +59,7 @@ module MergeRequests
merge_request
.
mark_as_unchecked
merge_request
.
mark_as_unchecked
end
end
merge_request
.
notice_added_references
(
merge_request
.
project
,
current_user
)
merge_request
.
create_new_cross_references!
(
merge_request
.
project
,
current_user
)
execute_hooks
(
merge_request
,
'update'
)
execute_hooks
(
merge_request
,
'update'
)
end
end
...
...
spec/models/concerns/mentionable_spec.rb
View file @
f3d4767d
...
@@ -29,7 +29,7 @@ describe Issue, "Mentionable" do
...
@@ -29,7 +29,7 @@ describe Issue, "Mentionable" do
end
end
end
end
describe
'#
notice_added_references
'
do
describe
'#
create_new_cross_references!
'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:issues
)
{
create_list
(
:issue
,
2
,
project:
project
)
}
let
(
:issues
)
{
create_list
(
:issue
,
2
,
project:
project
)
}
...
@@ -40,7 +40,7 @@ describe Issue, "Mentionable" do
...
@@ -40,7 +40,7 @@ describe Issue, "Mentionable" do
expect
(
SystemNoteService
).
not_to
receive
(
:cross_reference
)
expect
(
SystemNoteService
).
not_to
receive
(
:cross_reference
)
issue
.
description
=
'New description'
issue
.
description
=
'New description'
issue
.
notice_added_references
issue
.
create_new_cross_references!
end
end
it
'notifies new references'
do
it
'notifies new references'
do
...
@@ -49,7 +49,7 @@ describe Issue, "Mentionable" do
...
@@ -49,7 +49,7 @@ describe Issue, "Mentionable" do
expect
(
SystemNoteService
).
to
receive
(
:cross_reference
).
with
(
issues
[
1
],
any_args
)
expect
(
SystemNoteService
).
to
receive
(
:cross_reference
).
with
(
issues
[
1
],
any_args
)
issue
.
description
=
issues
[
1
].
to_reference
issue
.
description
=
issues
[
1
].
to_reference
issue
.
notice_added_references
issue
.
create_new_cross_references!
end
end
end
end
...
@@ -60,7 +60,7 @@ describe Issue, "Mentionable" do
...
@@ -60,7 +60,7 @@ describe Issue, "Mentionable" do
expect
(
SystemNoteService
).
not_to
receive
(
:cross_reference
)
expect
(
SystemNoteService
).
not_to
receive
(
:cross_reference
)
issue
.
update_attributes
(
description:
'New description'
)
issue
.
update_attributes
(
description:
'New description'
)
issue
.
notice_added_references
issue
.
create_new_cross_references!
end
end
it
'notifies new references'
do
it
'notifies new references'
do
...
@@ -69,7 +69,7 @@ describe Issue, "Mentionable" do
...
@@ -69,7 +69,7 @@ describe Issue, "Mentionable" do
expect
(
SystemNoteService
).
to
receive
(
:cross_reference
).
with
(
issues
[
1
],
any_args
)
expect
(
SystemNoteService
).
to
receive
(
:cross_reference
).
with
(
issues
[
1
],
any_args
)
issue
.
update_attributes
(
description:
issues
[
1
].
to_reference
)
issue
.
update_attributes
(
description:
issues
[
1
].
to_reference
)
issue
.
notice_added_references
issue
.
create_new_cross_references!
end
end
end
end
...
...
spec/support/mentionable_shared_examples.rb
View file @
f3d4767d
...
@@ -143,6 +143,6 @@ shared_examples 'an editable mentionable' do
...
@@ -143,6 +143,6 @@ shared_examples 'an editable mentionable' do
end
end
set_mentionable_text
.
call
(
new_text
)
set_mentionable_text
.
call
(
new_text
)
subject
.
notice_added_references
(
project
,
author
)
subject
.
create_new_cross_references!
(
project
,
author
)
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