Improve error output when copying project fails

pull/5076/head
Oliver Günther 8 years ago
parent aefe2b5570
commit c405b3977d
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 3
      app/mailers/user_mailer.rb
  2. 2
      app/views/user_mailer/copy_project_failed.html.erb
  3. 2
      app/views/user_mailer/copy_project_failed.text.erb
  4. 5
      app/workers/copy_project_job.rb

@ -115,9 +115,10 @@ class UserMailer < BaseMailer
end
end
def copy_project_failed(user, source_project, target_project_name)
def copy_project_failed(user, source_project, target_project_name, errors)
@source_project = source_project
@target_project_name = target_project_name
@errors = errors
open_project_headers 'Source-Project' => source_project.identifier,
'Author' => user.login

@ -30,3 +30,5 @@ See doc/COPYRIGHT.rdoc for more details.
<h1><%= link_to @source_project.name, project_url(@source_project) %></h1>
<%= t('copy_project.text.failed', source_project_name: @source_project.name, target_project_name: @target_project_name) %>
<%= @errors.join("<br/>".html_safe) %>

@ -31,3 +31,5 @@ See doc/COPYRIGHT.rdoc for more details.
<%= project_url(@source_project) %>
<%= t('copy_project.text.failed', source_project_name: @source_project.name, target_project_name: @target_project_name) %>
<%= @errors.join("\n") %>

@ -58,9 +58,9 @@ class CopyProjectJob < ApplicationJob
if target_project
UserMailer.copy_project_succeeded(user, source_project, target_project, errors).deliver_now
else
target_project_name = target_project_params[:name]
target_project_name = target_project_params['name']
UserMailer.copy_project_failed(user, source_project, target_project_name).deliver_now
UserMailer.copy_project_failed(user, source_project, target_project_name, errors).deliver_now
end
end
@ -106,6 +106,7 @@ class CopyProjectJob < ApplicationJob
else
errors = target_project.errors.full_messages
target_project = nil
logger.error("Copying project fails with validation errors: #{errors.join("\n")}")
end
end
rescue ActiveRecord::RecordNotFound => e

Loading…
Cancel
Save