From 44e1915d4f0e20cf445196ccc7e1d279c75ef0ce Mon Sep 17 00:00:00 2001 From: Oswaldo Ferreira Date: Tue, 4 Jun 2019 20:50:57 -0300 Subject: Persist tmp snippet uploads It persist temporary personal snippets under user/:id namespaces temporarily while creating a upload record to track it. If an user gets removed while it's still a tmp upload, it also gets removed. If the tmp upload is sent, the upload gets moved to personal_snippets/:id as before. The upload record also gets updated to the new model type as well. --- app/helpers/snippets_helper.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/helpers') diff --git a/app/helpers/snippets_helper.rb b/app/helpers/snippets_helper.rb index ecb2b2d707b..6ccc1fb2ed1 100644 --- a/app/helpers/snippets_helper.rb +++ b/app/helpers/snippets_helper.rb @@ -1,6 +1,16 @@ # frozen_string_literal: true module SnippetsHelper + def snippets_upload_path(snippet, user) + return unless user + + if snippet&.persisted? + upload_path('personal_snippet', id: snippet.id) + else + upload_path('user', id: user.id) + end + end + def reliable_snippet_path(snippet, opts = nil) if snippet.project_id? project_snippet_path(snippet.project, snippet, opts) -- cgit v1.2.3