##// END OF EJS Templates
Adds flash messages to files_controller#create (#19793)....
Jean-Philippe Lang -
r13861:fd034f734183
parent child
Show More
@@ -47,9 +47,16 class FilesController < ApplicationController
47 attachments = Attachment.attach_files(container, params[:attachments])
47 attachments = Attachment.attach_files(container, params[:attachments])
48 render_attachment_warning_if_needed(container)
48 render_attachment_warning_if_needed(container)
49
49
50 if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
50 if attachments[:files].present?
51 Mailer.attachments_added(attachments[:files]).deliver
51 if Setting.notified_events.include?('file_added')
52 Mailer.attachments_added(attachments[:files]).deliver
53 end
54 flash[:notice] = l(:label_file_added)
55 redirect_to project_files_path(@project)
56 else
57 flash.now[:error] = l(:label_attachment) + " " + l('activerecord.errors.messages.invalid')
58 new
59 render :action => 'new'
52 end
60 end
53 redirect_to project_files_path(@project)
54 end
61 end
55 end
62 end
@@ -106,4 +106,15 class FilesControllerTest < ActionController::TestCase
106 assert_equal Version.find(2), a.container
106 assert_equal Version.find(2), a.container
107 end
107 end
108
108
109 def test_create_without_file
110 set_tmp_attachments_directory
111 @request.session[:user_id] = 2
112
113 assert_no_difference 'Attachment.count' do
114 post :create, :project_id => 1, :version_id => ''
115 assert_response 200
116 assert_template 'new'
117 end
118 assert_select 'div.error', 'File is invalid'
119 end
109 end
120 end
General Comments 0
You need to be logged in to leave comments. Login now