-
-
Notifications
You must be signed in to change notification settings - Fork 494
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
4135 Individuals Requests Preserve Values #4142
Merged
cielf
merged 2 commits into
rubyforgood:main
from
elasticspoon:4135-request-value-preservation
Mar 7, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Partners::FamilyRequest do | ||
describe "Partners::FamilyRequest.new_with_attrs" do | ||
it "creates a new FamilyRequest with attributes" do | ||
attributes = [{item_id: 1, person_count: 3}] | ||
request = Partners::FamilyRequest.new_with_attrs(attributes) | ||
|
||
expect(request.items.length).to eq(1) | ||
expect(request.items.first.item_id).to eq(1) | ||
expect(request.items.first.person_count).to eq(3) | ||
end | ||
end | ||
|
||
describe "#items_attributes=" do | ||
let(:item_attributes) { {"0" => {item_id: 1, person_count: 2}, "1" => {item_id: 2, person_count: 3}} } | ||
let(:family_request) { Partners::FamilyRequest.new({}) } | ||
|
||
it "assigns items based on given attributes" do | ||
family_request.items_attributes = item_attributes | ||
expect(family_request.items.length).to eq(2) | ||
expect(family_request.items.first.item_id).to eq(1) | ||
expect(family_request.items.first.person_count).to eq(2) | ||
expect(family_request.items.last.item_id).to eq(2) | ||
expect(family_request.items.last.person_count).to eq(3) | ||
end | ||
|
||
it "creates instances of Item with correct attributes" do | ||
family_request.items_attributes = item_attributes | ||
expect(family_request.items.first).to be_an_instance_of(Partners::FamilyRequest::Item) | ||
expect(family_request.items.last).to be_an_instance_of(Partners::FamilyRequest::Item) | ||
end | ||
|
||
it "overrides existing items" do | ||
family_request = Partners::FamilyRequest.new({}, initial_items: 6) | ||
expect(family_request.items.length).to eq(6) | ||
|
||
family_request.items_attributes = item_attributes | ||
expect(family_request.items.length).to eq(2) | ||
expect(family_request.items.first.item_id).to eq(1) | ||
expect(family_request.items.first.person_count).to eq(2) | ||
expect(family_request.items.last.item_id).to eq(2) | ||
expect(family_request.items.last.person_count).to eq(3) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we combine these 2? System specs are expensive, so let's get all our expectations together :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually already drafted a PR to move the input tests to request specs: #4147. So they are separate because the check for invalid values will remain a system test while the other stuff will moved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dorner do you still feel this way? or can this PR proceed? I would also like to rebase this PR on top of #4099 cause they have some overlap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, since we're addressing it in a followup PR I'm OK with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dorner - so does that mean this one meets your approval now (sounds like it)?