@@ -47,9 +47,16 class FilesController < ApplicationController | |||
|
47 | 47 | attachments = Attachment.attach_files(container, params[:attachments]) |
|
48 | 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 | if Setting.notified_events.include?('file_added') | |
|
51 | 52 | Mailer.attachments_added(attachments[:files]).deliver |
|
52 | 53 | end |
|
54 | flash[:notice] = l(:label_file_added) | |
|
53 | 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' | |
|
60 | end | |
|
54 | 61 | end |
|
55 | 62 | end |
@@ -106,4 +106,15 class FilesControllerTest < ActionController::TestCase | |||
|
106 | 106 | assert_equal Version.find(2), a.container |
|
107 | 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 | 120 | end |
General Comments 0
You need to be logged in to leave comments.
Login now