Skip to content

Commit

Permalink
Bugfix: NoSuchKey error (#3746)
Browse files Browse the repository at this point in the history
  • Loading branch information
annaswims authored Jan 8, 2020
1 parent aefee4d commit d8e0826
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions app/controllers/concerns/form_attachment_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ def create
form_attachment_model = self.class::FORM_ATTACHMENT_MODEL
form_attachment = form_attachment_model.new
namespace = form_attachment_model.to_s.underscore.split('/').last
filtered_params = params.require(namespace).permit(:file_data)

file_data = params.require(namespace).permit(:file_data)

form_attachment.set_file_data!(file_data)
form_attachment.set_file_data!(filtered_params[:file_data])
form_attachment.save!
render(json: form_attachment)
end
Expand Down
5 changes: 3 additions & 2 deletions spec/controllers/v0/hca_attachments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
post(:create, params: { hca_attachment: {
file_data: fixture_file_upload('pdf_fill/extras.pdf')
} })

expect(JSON.parse(response.body)['data']['attributes']['guid']).to eq HcaAttachment.last.guid
guid = JSON.parse(response.body)['data']['attributes']['guid']
expect(guid).to eq HcaAttachment.last.guid
expect(File).to exist("spec/support/uploads/hca_attachments/#{guid}")
end

it 'validates input parameters' do
Expand Down

0 comments on commit d8e0826

Please sign in to comment.