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
605a4208
Commit
605a4208
authored
Apr 15, 2020
by
Sashi Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove store_mentions! in Snippets::CreateService
parent
58b0ba62
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
3 deletions
+43
-3
app/services/snippets/create_service.rb
app/services/snippets/create_service.rb
+1
-3
changelogs/unreleased/213557-remove-store_mentions.yml
changelogs/unreleased/213557-remove-store_mentions.yml
+5
-0
spec/services/snippets/create_service_spec.rb
spec/services/snippets/create_service_spec.rb
+37
-0
No files found.
app/services/snippets/create_service.rb
View file @
605a4208
...
...
@@ -38,9 +38,7 @@ module Snippets
private
def
save_and_commit
snippet_saved
=
@snippet
.
with_transaction_returning_status
do
@snippet
.
save
&&
@snippet
.
store_mentions!
end
snippet_saved
=
@snippet
.
save
if
snippet_saved
&&
Feature
.
enabled?
(
:version_snippets
,
current_user
)
create_repository
...
...
changelogs/unreleased/213557-remove-store_mentions.yml
0 → 100644
View file @
605a4208
---
title
:
Remove store_mentions! in Snippets::CreateService
merge_request
:
29581
author
:
Sashi Kumar
type
:
other
spec/services/snippets/create_service_spec.rb
View file @
605a4208
...
...
@@ -252,6 +252,39 @@ describe Snippets::CreateService do
end
end
shared_examples
'after_save callback to store_mentions'
do
context
'when mentionable attributes change'
do
let
(
:extra_opts
)
{
{
description:
"Description with
#{
user
.
to_reference
}
"
}
}
it
'saves mentions'
do
expect_next_instance_of
(
Snippet
)
do
|
instance
|
expect
(
instance
).
to
receive
(
:store_mentions!
).
and_call_original
end
expect
(
snippet
.
user_mentions
.
count
).
to
eq
1
end
end
context
'when mentionable attributes do not change'
do
it
'does not call store_mentions'
do
expect_next_instance_of
(
Snippet
)
do
|
instance
|
expect
(
instance
).
not_to
receive
(
:store_mentions!
)
end
expect
(
snippet
.
user_mentions
.
count
).
to
eq
0
end
end
context
'when save fails'
do
it
'does not call store_mentions'
do
base_opts
.
delete
(
:title
)
expect_next_instance_of
(
Snippet
)
do
|
instance
|
expect
(
instance
).
not_to
receive
(
:store_mentions!
)
end
expect
(
snippet
.
valid?
).
to
be
false
end
end
end
context
'when ProjectSnippet'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
...
...
@@ -265,6 +298,7 @@ describe Snippets::CreateService do
it_behaves_like
'snippet create data is tracked'
it_behaves_like
'an error service response when save fails'
it_behaves_like
'creates repository and files'
it_behaves_like
'after_save callback to store_mentions'
end
context
'when PersonalSnippet'
do
...
...
@@ -276,6 +310,9 @@ describe Snippets::CreateService do
it_behaves_like
'snippet create data is tracked'
it_behaves_like
'an error service response when save fails'
it_behaves_like
'creates repository and files'
pending
(
'See https://gitlab.com/gitlab-org/gitlab/issues/30742'
)
do
it_behaves_like
'after_save callback to store_mentions'
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