mardi 18 juillet 2017

Rspec for controller

def finding
  if params[:called_by] == ‘ATTACHMENT’
    Dir.mkdir('tmp/tmp_pdf') unless File.exists?('tmp/tmp_pdf')
    name = params[:ticket_attachment].original_filename
 end 
end

Above is my controller method.

it 'called attachment' do
    get :notifications, params: { id: users.user_id, called_by:'ATTACHMENT'}
    expect(response).to render_template(:finding) 

end

Above is my Spec for the Controller method.

on Running my spec , i am getting the error as

NoMethodError:
   undefined method `original_filename' for nil:NilClass

Looking forward for the solution, thanks in advance.

Aucun commentaire:

Enregistrer un commentaire