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

4516 fix child requests for inactive children #4699

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/partners/family_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def build_family_requests_attributes(params)
end
end

children = current_partner.children.active.where(id: children_ids).joins(:requested_items).select('children.*', :item_id)
children = current_partner.children.where(id: children_ids).joins(:requested_items).select('children.*', :item_id)

children_grouped_by_item_id = children.group_by(&:item_id)
children_grouped_by_item_id.map do |item_id, item_requested_children|
Expand Down
10 changes: 10 additions & 0 deletions spec/requests/partners/family_requests_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,15 @@

expect(response.request.flash[:notice]).to eql "Requested items successfully!"
end

it "creates the correct child item requests" do
partner.update!(status: :approved)

subject

expect(Partners::ChildItemRequest.find_by(child_id: children[0].id)).to be_present
expect(Partners::ChildItemRequest.find_by(child_id: children[1].id)).to be_nil
expect(Partners::ChildItemRequest.find_by(child_id: children[2].id)).to be_present
end
end
end