Commit eff8f975 authored by Alex Kalderimis's avatar Alex Kalderimis Committed by Jan Provaznik

Avoid incorrect cached values

this fixes https://gitlab.com/gitlab-org/gitlab-ee/issues/12780
parent b40c044f
......@@ -34,16 +34,22 @@ module DesignManagement
def create_and_commit_designs!
repository.create_if_not_exists
repository_actions = files.map do |file|
design = collection.find_or_create_design!(filename: file.original_filename)
# Do not inline `build_repository_action` here!
# We have to do this as two *separate* calls to #map so that the call
# to `new_file?` does not accidentally cache the wrong data half-way
# through the operation.
corresponding_designs = files.map do |file|
collection.find_or_create_design!(filename: file.original_filename)
end
actions = files.zip(corresponding_designs).map do |(file, design)|
build_repository_action(file, design)
end
repository.multi_action(current_user,
branch_name: target_branch,
message: commit_message,
actions: repository_actions)
actions: actions)
end
def build_repository_action(file, design)
......
---
title: 'Fixes #12780 by avoiding incorrect cached values'
merge_request: 14651
type: fixed
......@@ -140,6 +140,10 @@ describe DesignManagement::SaveDesignsService do
]
end
it 'returns information about both designs in the response' do
expect(service.execute).to include(designs: have_attributes(size: 2), status: :success)
end
it "creates 2 designs with a single version" do
expect { service.execute }.to change { issue.designs.count }.from(0).to(2)
expect(DesignManagement::Version.for_designs(issue.designs).size).to eq(1)
......
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