a1dert/lh-tickets-test — Issue #281: TypeError in Demands#update when re-request expense with attachments
Author: a1dert
Created: 2011-11-30 12:03:08+00:00
State: closed
Labels: resolved, tracker

Imported from lighthouse. Original ticket at: http://redtape.lighthouseapp.com/projects/59696/tickets/302. Created by Alexey Osipenko - 2011-06-03T13:09:37Z

1. Request expense with 2 or more attachments.
2. Edit this expense.
3. Mark one of attachments to remove.
4. Add new attachment.
5. Press request. You get an server error.

Details:
Showing /var/www/apps/redtape/staging/releases/20110602150353/app/views/demands/expenses/_notes.html.erb where line #16 raised:
@@@
can’t convert nil into String
@@@

Trace:
@@@ ruby
app/models/expense_attachment.rb:24:in `extname’
app/models/expense_attachment.rb:24:in `file_name’
app/helpers/attachments_helper.rb:12:in `link_to_attachment’
app/views/demands/expenses/notes.html.erb:16:in `_app_views_demands_expenses_notes_html_erb__505838749_60472220_7568780’
app/views/demands/expenses/notes.html.erb:14:in `_app_views_demands_expenses_notes_html_erb__505838749_60472220_7568780’
app/helpers/demands_helper.rb:21:in `render_demand_partial’
app/views/demands/demand.html.erb:15:in `_app_views_demands_demand_html_erb___2090747201_60561420_2839230’
app/views/demands/update.js.erb:4:in `_app_views_demands_update_js_erb___272592078_60588480_0’
app/controllers/demands_controller.rb:80:in `update’
@@@

Request:
@@@ javascript
{"remotipart_submitted"=>"true",
“format”=>"js",
“demand”=>{"expense_items_attributes"=>{"0"=>{"title"=>"5 items",
“cost”=>"2",
“id”=>"167",
“_destroy”=>"0"},
“1”=>{"title"=>"5 items",
“cost”=>"2",
“id”=>"168",
“_destroy”=>"0"}},
“cost_center_id”=>"83",
“title”=>"5 paper clips",
“details”=>"5 items",
“expense_attachments_attributes”=>{"0"=>{"id"=>"24",
“_destroy”=>"0"},
“1”=>{"id"=>"25",
“_destroy”=>"0"},
“2”=>{"id"=>"31",
“_destroy”=>"1"},
“4”=>{"file"=>#,
@content_type=“image/png”>}}},
“authenticity_token”=>"ciCtFHvQiP+Q5DR0UbVxgbQOHj+E3dY39LFlIhZKA80=",
“_method”=>"put",
“utf8”=>"\342\234\223",
“model_type”=>"expenses",
“id”=>"270"}
@@@

According to: [story 6371](https://tracker.anahoret.com/projects/44/stories/6371 "story 6371")