gitlabhq/gitlabhq — pull request #6467 by tudorpavel (2014-03-04 16:04:30+00:00)
Title: Add feature to be able to upload a file to an issue

The idea of this feature is to have the possibility of uploading a file to an issue, not just to comments. This implementation works just for the simpler case of only one file per issue.

Feature requests:
* http://feedback.gitlab.com/forums/176466-general/suggestions/4501700-allow-image-attachments-when-creating-new-issues
* http://feedback.gitlab.com/forums/176466-general/suggestions/4095092-allow-file-uploads-to-an-issue

#### User Interface

The implementation consists of:
* a slightly modified add/edit issue form
* a slightly modified show issue page

##### Add/Edit Form

Before:
![edit_page_before_issue_file_upload](https://f.cloud.github.com/assets/2506871/2322684/27e2d38a-a3b4-11e3-9777-5564a4338190.png)

After, without any attachment:
![edit_page_after_issue_file_upload](https://f.cloud.github.com/assets/2506871/2322703/46653aa0-a3b4-11e3-9b97-0ede19ad7c96.png)

After, with image attachment:
![edit_page_after_issue_file_upload_with_img_attachment](https://f.cloud.github.com/assets/2506871/2322706/4e279404-a3b4-11e3-9d67-d77ab9b5ac31.png)

After, with non-image file attachment:
![edit_page_after_issue_file_upload_with_attachment](https://f.cloud.github.com/assets/2506871/2322715/5a48525a-a3b4-11e3-817e-370a4e40e4ce.png)

##### Show page

Before:
![show_page_before_issue_file_upload](https://f.cloud.github.com/assets/2506871/2322731/89132344-a3b4-11e3-9346-44ab2d2d4d41.png)

After, with image attachment:
![show_page_after_issue_file_upload_with_img_attachment](https://f.cloud.github.com/assets/2506871/2322733/9257a3da-a3b4-11e3-8bdc-75e0c5debfbb.png)

After, with non-image file attachment:
![show_page_after_issue_file_upload_with_attachment](https://f.cloud.github.com/assets/2506871/2322743/9f998432-a3b4-11e3-966a-becba48a0307.png)

#### Implementation
* migration to add *attachment* column to the *issues* table
* modify *Issue* model to add CarrierWave attachment the same way it's done for *Note*
* add issue ```:delete_attachment``` route
* add attachment code and style in views so it looks and works very similar to the notes attachment
* had to generalize ```FilesController#download``` to work with any model