Skip to content
This repository was archived by the owner on Nov 6, 2021. It is now read-only.

Customizable partner form#287

Merged
seanmarcia merged 5 commits intomasterfrom
customizable_partner_form
Apr 12, 2020
Merged

Customizable partner form#287
seanmarcia merged 5 commits intomasterfrom
customizable_partner_form

Conversation

@seanmarcia
Copy link
Copy Markdown
Member

This is part of the customizations to allow diaper banks to select which sections of the partner form they want them to be able to edit.

Copy link
Copy Markdown
Collaborator

@edwinthinks edwinthinks left a comment

Choose a reason for hiding this comment

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

Looks pretty good! I left some comments :)

end

def valid_partner_form_creation_request(
diaper_bank_id: 123,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
diaper_bank_id: 123,
diaper_bank_id: Faker::Number.number,


describe "#partials_to_show" do
let(:partner) { create(:partner, diaper_bank_id: 100) }
it 'has 9 partials when there are no displayable partials configured' do
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
it 'has 9 partials when there are no displayable partials configured' do
it 'has 9 partials when there are no displayable partials configured' do


it 'displays the number of displayable partials when they are configured' do
partner.diaper_bank_id = 100
FactoryBot.create(:partner_form, diaper_bank_id: 100,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
FactoryBot.create(:partner_form, diaper_bank_id: 100,
FactoryBot.create(:partner_form, diaper_bank_id: partner.id,

Since partner is already defined above with let could we just use the partner from there?

Comment thread spec/models/partner_spec.rb Outdated
describe "#partials_to_show" do
let(:partner) { create(:partner, diaper_bank_id: 100) }
it 'has 9 partials when there are no displayable partials configured' do
expect(partner.partials_to_show.size).to eq(9)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
expect(partner.partials_to_show.size).to eq(9)
expect(partner.partials_to_show).to eq(Partner::ALL_PARTIALS)

^ this might make the test a bit more robust, so when you add a new field you won't have to worry about fixing this spec.

Comment thread app/models/partner.rb Outdated
end

def displayable_partials
PartnerForm.find_by(diaper_bank_id: diaper_bank_id)&.sections
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
PartnerForm.find_by(diaper_bank_id: diaper_bank_id)&.sections
PartnerForm.find_by(diaper_bank_id: diaper_bank_id)&.sections

Can we can add the has_one association to get this instead of putting a query here?

  has_one :partner_form, primary_key: :diaper_bank_id, foreign_key: :diaper_bank_id

^ This should work and allow you to use partner_form in place of the Partner.find_by(...)

Comment thread app/models/partner.rb Outdated
displayable_partials || ALL_PARTIALS
end

def displayable_partials
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we put this as a private method since it is only being used in the partial_to_show right now?

Comment thread spec/models/partner_form_spec.rb Outdated

RSpec.describe PartnerForm, type: :model do
subject do
described_class.new(diaper_bank_id: 1)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
described_class.new(diaper_bank_id: 1)
described_class.new(diaper_bank_id: Faker::Number.number)

@seanmarcia seanmarcia force-pushed the customizable_partner_form branch from 0d9ed76 to c48e318 Compare April 6, 2020 23:08
@seanmarcia seanmarcia force-pushed the customizable_partner_form branch from c48e318 to dcdad79 Compare April 7, 2020 00:33
@seanmarcia
Copy link
Copy Markdown
Member Author

Addressed your comments. Most of them anyway.

Copy link
Copy Markdown
Collaborator

@edwinthinks edwinthinks left a comment

Choose a reason for hiding this comment

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

@seanmarcia seanmarcia merged commit cb75fbd into master Apr 12, 2020
@seanmarcia seanmarcia deleted the customizable_partner_form branch May 12, 2020 20:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants