Skip to content

Commit

Permalink
4635: Comment is missing from purchase details (#4642)
Browse files Browse the repository at this point in the history
* chore(model/purchase): add comment_view

* feat(view/purchases/show): show comment on purchase details

* chore(model/purchase): remove comment_view

* fix(purchases/show): indent html

* chore(purchases_requests_rspec): use expected value on test

* fix(purchases_requests_rspec): use freeze_time on show purchase info test
  • Loading branch information
victorhwmn authored Sep 16, 2024
1 parent 3963287 commit d59c559
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
23 changes: 17 additions & 6 deletions app/views/purchases/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,28 @@
<div class="card-body p-0">
<table class="table">
<thead>
<tr>
<th>Date of Purchase:</th>
<th>Vendor:</th>
<th>Storage Location:</th>
</tr>
</thead>
<tbody>
<tr>
<th>Date of Purchase:</th>
<th>Vendor:</th>
<th>Storage Location:</th>
<td><%= @purchase.issued_at.to_fs(:distribution_date) %> (entered: <%= @purchase.created_at.to_fs(:distribution_date) %>)</td>
<td><%= @purchase.purchased_from_view %></td>
<td><%= @purchase.storage_view %></td>
</tr>
</table>
<table class="table">
<thead>
<tr>
<th>Comment:</th>
</tr>
</thead>
<tbody>
<tr>
<td><%= @purchase.issued_at.to_fs(:distribution_date) %> (entered: <%= @purchase.created_at.to_fs(:distribution_date) %>)</td>
<td><%= @purchase.purchased_from_view %></td>
<td><%= @purchase.storage_view %></td>
<td><%= @purchase.comment || '' %></td>
</tr>
</table>
</div>
Expand Down
16 changes: 15 additions & 1 deletion spec/requests/purchases_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,21 @@

describe "GET #show" do
let(:item) { create(:item) }
let!(:purchase) { create(:purchase, :with_items, item: item) }
let(:storage_location) { create(:storage_location, organization: organization, name: 'Some Storage') }
let(:vendor) { create(:vendor, organization: organization, business_name: 'Another Business') }
let(:purchase) { create(:purchase, :with_items, comment: 'Fine day for diapers, it is.', created_at: 1.month.ago, issued_at: 1.day.ago, item: item, storage_location: storage_location, vendor: vendor) }

it "shows the purchase info" do
freeze_time do
date_of_purchase = "#{1.day.ago.to_fs(:distribution_date)} (entered: #{1.month.ago.to_fs(:distribution_date)})"

get purchase_path(id: purchase.id)
expect(response.body).to include(date_of_purchase)
expect(response.body).to include('Another Business')
expect(response.body).to include('Some Storage')
expect(response.body).to include('Fine day for diapers, it is.')
end
end

it "shows an enabled edit button" do
get purchase_path(id: purchase.id)
Expand Down

0 comments on commit d59c559

Please sign in to comment.