akshatpradhan/compliance_chimp — pull request #31 by adamico (2014-03-19 21:41:09+00:00)
Title: Rewrite of edit proof feature

Complete rewriting of the edit proof feature.

I haven't used any hidden fields in the edit proof form and I removed user_id from the new proof form (these form can be DRYed up with a partial rendering common proof fields). Moreover I protected proof mass assignment by allowing only image_url attribute, no need to allow other fields since they're either assigned from the parent resource (requirement_id) or directly in the controller (user_id). This could help for the future migration to Rails4 and strong parameters.

I added logic in requirements#index to render the Attach Proof link or the image and Edit Proof link according to the presence of a user submitted proof for each requirement. The user_proof method is called now proof_for and is used in the helper which renders the image for a proof. I haven't added any more helpers which certainly clean the view but add unneeded complexity at the moment.

I refactored the existing specs for browsing and creating proofs (DRYed them up, using title attribute for links) and added 2 specs for editing proofs.