Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sets project image on attribute creation (closes #264) #377

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jonnatas
Copy link
Contributor

@jonnatas jonnatas commented Sep 8, 2016

  • Uses 'image_url' as instance variable to be able to set 'image_url'
  • It evades the problem of updating the image of a null 'project_attribute' on repository creation

@rafamanzo
Copy link
Member

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.

@rafamanzo
Copy link
Member

rafamanzo commented Sep 9, 2016

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?

@jonnatas
Copy link
Contributor Author

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.

Copy link
Member

@rafamanzo rafamanzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also there is no acceptance test for such feature. Do you think we can take this opportunity to choose it?


subject { post :create, :project => subject_params }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call to post is better suited into a before do; end. Is there a special reason for making it within the subject?

subject { post :create, :project => subject_params }

it 'should increase total number of project_attributes' do
expect{subject}.to change{@user.project_attributes.count}.by(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of touching the database, what do you think about creating mocks and asserting they are called? If need help with the mocking concepts, please let me know.

Copy link
Contributor Author

@jonnatas jonnatas Nov 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafamanzo yes, can you give me a hand with the mocking?

@@ -56,6 +61,7 @@
end

it { is_expected.to render_template(:new) }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful with blank spaces and lines. (But a blank line at the end of the file is desirable)

- It evades the problem of updating the image of a null repository

Signed-off-by: jonnatas <jonatas_lenon@hotmail.com>
Signed-off-by: DylanGuedes <djmgguedes@gmail.com>
Signed-off-by: jonnatas <jonatas_lenon@hotmail.com>
Signed-off-by: DylanGuedes <djmgguedes@gmail.com>
Signed-off-by: jonnatas <jonatas_lenon@hotmail.com>
Signed-off-by: MarcosDDourado <marcosdourado92@gmail.com>

# GET /projects/new
def new
@project = Project.new
end

def fetch_image_url
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about setting this as a private method?


Then(/^I insert the url on the image field/) do
fill_in "project_image_url", with: "https://www.nasa.gov/sites/default/files/styles/image_card_4x3_ratio/public/thumbnails/image/leisa_christmas_false_color.png?itok=Jxf0IlS4"
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing endline

@diegoamc
Copy link
Contributor

diegoamc commented Nov 5, 2016

ping @jonnatas

@rafamanzo
Copy link
Member

@vitorbaraujo @oliveiraMarcelo, This PR is almost complete. Would you like to proceed with this one?

@vitorbaraujo
Copy link
Contributor

vitorbaraujo commented Apr 26, 2017

We will put this issue in our backlog and attack it on our next sprint, is that ok?

@paulormm
Copy link

That's ok. Thanks.

@oliveiraMarcelo
Copy link

I'm working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants