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

Add response with error message on failure destroy action #2920

Conversation

bitberry-dev
Copy link

Hello again!

Now I noticed bug in admin when validations prevent destroy.
Your resource controller doesn't handle js format when destroy failures but your js code expects error message
2018-10-18 2 31 46

Test and fix in commit! :)

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Great work, thanks! Just left a possible improvement. Let me know what do you think!


def check_destroy_constraints
return unless name == 'undestroyable'
errors.add :base, 'You cant destroy undestroyable things!'
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not crazy about You cant destroy undestroyable things! I think there is a better way to phrase this.

We definitely need to add an apostrophe: You can't destroy undestroyable things!

Also, we probably want to add this to en.yml instead of just writing the string.

Copy link
Author

Choose a reason for hiding this comment

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

This validation is only for testing as you can see. Adding it to en.yml is weird. But if you do not like the phrase itself, then you can offer absolutely any one to your taste.

Copy link
Contributor

Choose a reason for hiding this comment

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

@bitberries That's fair, let's not worry about putting it in yaml then! I know it's picky, but I'd like to at least see the apostrophe :)

Copy link
Author

Choose a reason for hiding this comment

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

@bitberry-dev bitberry-dev force-pushed the feature/backend_add_error_message_on_destroy_action branch from 518765f to 7973a7a Compare December 11, 2018 23:45
@kennyadsl
Copy link
Member

@bitberryru failures should go away if you rebase against master, thanks!

@bitberry-dev bitberry-dev force-pushed the feature/backend_add_error_message_on_destroy_action branch from 7973a7a to 3e4e7fb Compare January 9, 2019 22:29
@bitberry-dev
Copy link
Author

@bitberryru failures should go away if you rebase against master, thanks!

Thank you, done.

Copy link
Contributor

@aitbw aitbw left a comment

Choose a reason for hiding this comment

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

Hey @bitberryru, I have left you just one comment I'd like you to address whenever you can. Thanks a lot! 🎉

context 'js format' do
subject { delete :destroy, params: params, format: 'js' }

it 'responses with error message' do
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you change responses for responds? Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

@aitbw good catch!

Copy link
Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@jacobherrington jacobherrington left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @bitberryru 👍

@bitberry-dev bitberry-dev force-pushed the feature/backend_add_error_message_on_destroy_action branch from 3e4e7fb to 582ab65 Compare January 14, 2019 03:13
@kennyadsl kennyadsl merged commit 8c8986a into solidusio:master Jan 14, 2019
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

4 participants