From 49c127b24d60e2dc86e39fffb8009caa3c279b4b Mon Sep 17 00:00:00 2001 From: McEileen Date: Sun, 15 Dec 2024 17:15:25 -0500 Subject: [PATCH 1/2] fix partner view to display distribution scheduled date, not date of entry --- app/views/partners/show.html.erb | 2 +- spec/system/partner_system_spec.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/views/partners/show.html.erb b/app/views/partners/show.html.erb index e1280b31f6..2477a7e687 100644 --- a/app/views/partners/show.html.erb +++ b/app/views/partners/show.html.erb @@ -238,7 +238,7 @@ <% @partner_distributions.each do |dist| %> - <%= dist.created_at.strftime("%m/%d/%Y") %> + <%= dist.issued_at.strftime("%m/%d/%Y") %> <%= dist.storage_location.name %> <%= dist.line_items.total %> diff --git a/spec/system/partner_system_spec.rb b/spec/system/partner_system_spec.rb index 59c6d771e5..f83b1bdcd1 100644 --- a/spec/system/partner_system_spec.rb +++ b/spec/system/partner_system_spec.rb @@ -317,6 +317,21 @@ end end end + + context "when viewing prior distributions" do + let(:partner) do + partner = create(:partner, :approved) + partner.distributions << create(:distribution, :with_items, :past, item_quantity: 1231) + partner + end + it "displays distribution scheduled date" do + visit partner_path(partner.id) + partner.distributions.each do |distribution| + expect(page).to have_content(distribution.issued_at.strftime("%m/%d/%Y")) + expect(page).to_not have_content(distribution.created_at.strftime("%m/%d/%Y")) + end + end + end end describe "#new" do From 2f274f544911937dd70595f9c325d4f2805c01c6 Mon Sep 17 00:00:00 2001 From: McEileen Date: Sat, 4 Jan 2025 21:10:06 -0500 Subject: [PATCH 2/2] use request spec instead of system spec to verify date displayed --- spec/requests/partners_requests_spec.rb | 16 ++++++++++++++-- spec/system/partner_system_spec.rb | 15 --------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/spec/requests/partners_requests_spec.rb b/spec/requests/partners_requests_spec.rb index 9084b6251d..52bb315b9f 100644 --- a/spec/requests/partners_requests_spec.rb +++ b/spec/requests/partners_requests_spec.rb @@ -87,7 +87,11 @@ response end - let(:partner) { create(:partner, organization: organization, status: :approved) } + let(:partner) do + partner = create(:partner, organization: organization, status: :approved) + partner.distributions << create(:distribution, :with_items, :past, item_quantity: 1231) + partner + end let!(:family1) { FactoryBot.create(:partners_family, guardian_zip_code: '45612-123', partner: partner) } let!(:family2) { FactoryBot.create(:partners_family, guardian_zip_code: '45612-126', partner: partner) } let!(:family3) { FactoryBot.create(:partners_family, guardian_zip_code: '45612-123', partner: partner) } @@ -107,6 +111,14 @@ context "html" do let(:response_format) { 'html' } + it "displays distribution scheduled date" do + subject + partner.distributions.each do |distribution| + expect(subject.body).to include(distribution.issued_at.strftime("%m/%d/%Y")) + expect(subject.body).to_not include(distribution.created_at.strftime("%m/%d/%Y")) + end + end + context "without org admin" do it 'should not show the manage users button' do expect(subject).to be_successful @@ -114,7 +126,7 @@ end end - context "without org admin" do + context "with org admin" do before(:each) do user.add_role(Role::ORG_ADMIN, organization) end diff --git a/spec/system/partner_system_spec.rb b/spec/system/partner_system_spec.rb index f83b1bdcd1..59c6d771e5 100644 --- a/spec/system/partner_system_spec.rb +++ b/spec/system/partner_system_spec.rb @@ -317,21 +317,6 @@ end end end - - context "when viewing prior distributions" do - let(:partner) do - partner = create(:partner, :approved) - partner.distributions << create(:distribution, :with_items, :past, item_quantity: 1231) - partner - end - it "displays distribution scheduled date" do - visit partner_path(partner.id) - partner.distributions.each do |distribution| - expect(page).to have_content(distribution.issued_at.strftime("%m/%d/%Y")) - expect(page).to_not have_content(distribution.created_at.strftime("%m/%d/%Y")) - end - end - end end describe "#new" do