Commit c93620f6 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'fj-avoid-updating-snippet-content-when-not-present' into 'master'

Avoid updating snippet content when snippet_files content is not present

See merge request gitlab-org/gitlab!34865
parents d64f6011 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)
......
---
title: Avoid updating snippet content when snippet_files content is not present
merge_request: 34865
author:
type: fixed
......@@ -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' }] }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment