codeforboston / cambridge_energy_app

EnerSave is designed to help and encourage Cambridge residents to reduce their electric bills.
https://www.enersaveapp.org/
MIT License
33 stars 25 forks source link

Fixed broken tip feedback submission #308

Closed FrankCardillo closed 7 years ago

FrankCardillo commented 7 years ago

It seems the problem was with pundit. When pundit was added, the UserTips controller and the UserTips policy were not properly configured.

shauncarland-old-account commented 7 years ago

@FrankCardillo this looks good! Can I make a suggestion though? It might be worth writing in a test to ensure that this issue is fixed. If you want, I can write one for you or help you do it. :)

FrankCardillo commented 7 years ago

@shauncarland @mzagaja In trying to write some tests for the controller actions other than create I realized that they aren't really implemented. Does this controller really need all of those actions? Should we consider limiting the actions associated with this controller? Also, any feedback on the test I did write would be greatly appreciated, thanks!

shauncarland-old-account commented 7 years ago

@FrankCardillo Hmm, I'm not sure which specs we should add or which we shouldn't...I think though for this PR you should stick with just doing the create spec for the user tips. There's a few more things you can test with this spec though

What happens when a user isn't logged in and they try to submit a tip? What happens when the parameters submitted are invalid? These are important things to ensure work correctly if we want to avoid problems. This guide is really helpful if you want to take a look:

http://everydayrails.com/2012/04/07/testing-series-rspec-controllers.html