Skip to content

Conversation

Budmin
Copy link
Contributor

@Budmin Budmin commented Sep 16, 2025

Resolves #5223

Description

The error message related to partners requesting Items where visible_to_partners is false now specifies which item and which children are causing the error.

NOTE: There is a small change unrelated to the specific issue. In the app/views/layouts/partners/application.html.erb file, there were two overlapping "X" icons to dismiss the error message. I've removed one of them so now there's just one icon.

Type of change

  • Bug fix (This is really more of a UI/UX improvement, but this is the most fitting option)
  • This change doesn't seem to affect any current documentation, and I don't think this warrants adding documentation related to this kind of error. However, I'm willing to address documentation concerns if there are any.

How Has This Been Tested?

I've added a test to the spec/requests/partners/family_requests_requests_spec.rb file that expects the format of the error message to include details about a non-visible item, and the child requesting it.

Screenshots

Before:

before

After:

after

end

def validate_visible_items!(child_ids)
invisible_item_requests = current_partner
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can reuse most if not all of the query that was created earlier. You can pass the query object into this method and just add the changes you need onto it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Having said that, all of this is starting to seem very heavy for controller logic. I think we should move most of this to the service class.

family_requests_attributes = build_family_requests_attributes(params)
begin
family_requests_attributes = build_family_requests_attributes(params)
rescue ArgumentError => e
Copy link
Collaborator

Choose a reason for hiding this comment

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

ArgumentError is a built-in Ruby exception that shouldn't be used for business logic validation. Probably best to create your own error class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Where would be the best place for the error class?

The file that looks most like is app/events/inventory_error.rb, so something like app/events/item_visibility_error.rb?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we're moving this to the service class, you can define the error inside the class itself.

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.

What should happen to child requests if an item is made not-visible-to-partners/inactive
2 participants