Open jonnatas opened 8 years ago
Welcome @jonnatas !
You've got the code right. Congratulations!
What do you think about taking this opportunity to enhance the ProjectsController#create
unit tests? The case for valid fields lack the proper mock for current_user.project_attributes.create(project_id: @project.id)
. And the case with invalid fields lacks a check that this was not called.
What do you think about making image_url = project_params.delete(:image_url)
a before action? Then applied only for create
and update
.
And if you are brave, what about making the set_project
calls before actions as well?
We created a new test for projects_controller#create that checks if the action also increased the total number of users and rewrited image_url to be a before_action to be reusable in projects_controller#update. We also try'd to do a better mock for the scenarios that you asked for, but It was tough, mainly because we can't finded a proper way to use "receive" (looks like it can't be usable with this configuration of rspec).
We can still trying if you really need the other mocks, but maybe we will need some help haha.
ping @jonnatas
@vitorbaraujo @oliveiraMarcelo, This PR is almost complete. Would you like to proceed with this one?
We will put this issue in our backlog and attack it on our next sprint, is that ok?
That's ok. Thanks.
I'm working on it.