Skip to content

Commit

Permalink
feat(view/purchases/show): show comment on purchase details
Browse files Browse the repository at this point in the history
  • Loading branch information
victorhwmn committed Sep 7, 2024
1 parent 4f96571 commit 1731bfe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/views/purchases/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@
<td><%= @purchase.storage_view %></td>
</tr>
</table>
<table class="table">
<thead>
<tr>
<th>Comment:</th>
</tr>
</thead>
<tbody>
<tr>
<td><%= @purchase.comment_view %></td>
</tr>
</table>
</div>
</div>
</div>
Expand Down
15 changes: 14 additions & 1 deletion spec/requests/purchases_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,20 @@

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, item: item, storage_location: storage_location, comment: 'Fine day for diapers, it is.') }

it "shows the purchase info" do
escaped_html_comment = CGI.escapeHTML(purchase.comment_view)
date_of_purchase = "#{purchase.issued_at.to_fs(:distribution_date)} (entered: #{purchase.created_at.to_fs(:distribution_date)})"

get purchase_path(id: purchase.id)
expect(response.body).to include(date_of_purchase)
expect(response.body).to include(purchase.purchased_from_view)
expect(response.body).to include(purchase.storage_view)
expect(response.body).to include(escaped_html_comment)
end

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

0 comments on commit 1731bfe

Please sign in to comment.