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
7abd7d2d
Commit
7abd7d2d
authored
Sep 14, 2021
by
Gary Holtz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip keep_around commit callback if `skip_keep_around_commits` is true
Changelog: performance
parent
a55c2106
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
app/models/note.rb
app/models/note.rb
+1
-1
spec/models/note_spec.rb
spec/models/note_spec.rb
+11
-0
No files found.
app/models/note.rb
View file @
7abd7d2d
...
@@ -149,7 +149,7 @@ class Note < ApplicationRecord
...
@@ -149,7 +149,7 @@ class Note < ApplicationRecord
scope
:like_note_or_capitalized_note
,
->
(
text
)
{
where
(
'(note LIKE ? OR note LIKE ?)'
,
text
,
text
.
capitalize
)
}
scope
:like_note_or_capitalized_note
,
->
(
text
)
{
where
(
'(note LIKE ? OR note LIKE ?)'
,
text
,
text
.
capitalize
)
}
before_validation
:nullify_blank_type
,
:nullify_blank_line_code
before_validation
:nullify_blank_type
,
:nullify_blank_line_code
after_save
:keep_around_commit
,
if: :for_project_noteable?
,
unless:
:importing?
after_save
:keep_around_commit
,
if: :for_project_noteable?
,
unless:
->
{
importing?
||
skip_keep_around_commits
}
after_save
:expire_etag_cache
,
unless: :importing?
after_save
:expire_etag_cache
,
unless: :importing?
after_save
:touch_noteable
,
unless: :importing?
after_save
:touch_noteable
,
unless: :importing?
after_destroy
:expire_etag_cache
after_destroy
:expire_etag_cache
...
...
spec/models/note_spec.rb
View file @
7abd7d2d
...
@@ -108,6 +108,17 @@ RSpec.describe Note do
...
@@ -108,6 +108,17 @@ RSpec.describe Note do
end
end
describe
'callbacks'
do
describe
'callbacks'
do
describe
'#keep_around_commit'
do
it
'skips #keep_around_commit if `skip_keep_around_commits` is true '
do
noteable
=
create
(
:issue
)
note
=
build
(
:note
,
project:
noteable
.
project
,
noteable:
noteable
,
skip_keep_around_commits:
true
)
expect
(
note
).
not_to
receive
(
:keep_around_commit
)
note
.
save!
end
end
describe
'#notify_after_create'
do
describe
'#notify_after_create'
do
it
'calls #after_note_created on the noteable'
do
it
'calls #after_note_created on the noteable'
do
noteable
=
create
(
:issue
)
noteable
=
create
(
:issue
)
...
...
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