Skip to content

Commit

Permalink
fix(purchases_requests_rspec): use freeze_time on show purchase info …
Browse files Browse the repository at this point in the history
…test
  • Loading branch information
victorhwmn committed Sep 14, 2024
1 parent 83ee754 commit b7cdc30
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions spec/requests/purchases_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,18 +264,21 @@

describe "GET #show" do
let(:item) { create(: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) }
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.', item: item, storage_location: storage_location, vendor: vendor) }

it "shows the purchase info" do
date_of_purchase = "#{1.day.ago.to_fs(:distribution_date)} (entered: #{1.month.ago.to_fs(:distribution_date)})"
freeze_time do
purchase.update(created_at: 1.month.ago, issued_at: 1.day.ago)
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.')
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
Expand Down

0 comments on commit b7cdc30

Please sign in to comment.