allows for adding an attachment

pull/243/head
Jens Ulferts 11 years ago
parent 44f7e3c271
commit fe274ad071
  1. 5
      app/controllers/work_packages_controller.rb
  2. 23
      spec/controllers/work_packages_controller_spec.rb

@ -60,6 +60,11 @@ class WorkPackagesController < ApplicationController
wp = new_work_package wp = new_work_package
if wp.save if wp.save
flash[:notice] = I18n.t(:notice_successful_create)
Attachment.attach_files(wp, params[:attachments])
render_attachment_warning_if_needed(wp)
redirect_to(work_package_path(wp)) redirect_to(work_package_path(wp))
else else
respond_to do |format| respond_to do |format|

@ -243,18 +243,37 @@ describe WorkPackagesController do
describe 'w/ beeing a member describe 'w/ beeing a member
w/ having the necessary permissions w/ having the necessary permissions
w/ having an successful save' do w/ having an successful save' do
let(:params) { { :project_id => project.id, :work_package => { } } }
become_member_with_permissions [:add_work_packages] become_member_with_permissions [:add_work_packages]
before do before do
controller.should_receive(:new_work_package).and_return(stub_issue) controller.should_receive(:new_work_package).and_return(stub_issue)
stub_issue.should_receive(:save).and_return(true) stub_issue.should_receive(:save).and_return(true)
post 'create', :project_id => project.id
end end
it 'redirect to show' do it 'redirect to show' do
post 'create', params
response.should redirect_to(work_package_path(stub_issue)) response.should redirect_to(work_package_path(stub_issue))
end end
it 'should show a flash message' do
disable_flash_sweep
post 'create', params
flash[:notice].should == I18n.t(:notice_successful_create)
end
it 'should attach attachments if those are provided' do
params[:attachments] = 'attachment-blubs-data'
Attachment.should_receive(:attach_files).with(stub_issue, params[:attachments])
controller.stub!(:render_attachment_warning_if_needed)
post 'create', params
end
end end
describe 'w/ beeing a member describe 'w/ beeing a member

Loading…
Cancel
Save