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

4635: Comment is missing from purchase details #4642

Merged
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
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>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you fix up the spacing here? Nested elements like tr and td should be indented more than the parent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed here 834f25f
I also fixed the indentation of the tr and td tags from the table above

</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