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
f763dbc1
Commit
f763dbc1
authored
Jun 18, 2020
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid updating snippet content when not present
parent
cd4e4045
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
1 deletion
+19
-1
app/services/snippets/update_service.rb
app/services/snippets/update_service.rb
+2
-1
changelogs/unreleased/fj-avoid-updating-snippet-content-when-not-present.yml
...ed/fj-avoid-updating-snippet-content-when-not-present.yml
+5
-0
spec/services/snippets/update_service_spec.rb
spec/services/snippets/update_service_spec.rb
+12
-0
No files found.
app/services/snippets/update_service.rb
View file @
f763dbc1
...
...
@@ -38,7 +38,8 @@ module Snippets
# Once we can perform different operations through this service
# we won't need to keep track of the `content` and `file_name` fields
if
snippet_files
.
any?
params
.
merge!
(
content:
snippet_files
[
0
].
content
,
file_name:
snippet_files
[
0
].
file_path
)
params
[
:content
]
=
snippet_files
[
0
].
content
if
snippet_files
[
0
].
content
params
[
:file_name
]
=
snippet_files
[
0
].
file_path
end
snippet
.
assign_attributes
(
params
)
...
...
changelogs/unreleased/fj-avoid-updating-snippet-content-when-not-present.yml
0 → 100644
View file @
f763dbc1
---
title
:
Avoid updating snippet content when snippet_files content is not present
merge_request
:
34865
author
:
type
:
fixed
spec/services/snippets/update_service_spec.rb
View file @
f763dbc1
...
...
@@ -349,6 +349,18 @@ describe Snippets::UpdateService do
end
end
context
'when snippet_file content is not present'
do
let
(
:snippet_files
)
{
[{
action: :move
,
previous_path:
file_path
,
file_path:
'new_file_path'
}]
}
it
'does not update snippet content'
do
content
=
snippet
.
content
expect
(
subject
).
to
be_success
expect
(
snippet
.
reload
.
content
).
to
eq
content
end
end
context
'when snippet_files param is invalid'
do
let
(
:snippet_files
)
{
[{
action:
'invalid_action'
}]
}
...
...
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