Simplify tests checking dates are present

When we create a record like a debate or an event and we check the page
content, we want to make sure that today's date is present, since it's
the date where the record is supposed to have been created.

This way we avoid querying the database after the browser has been
started.
This commit is contained in:
Javi Martín
2021-04-10 20:33:07 +02:00
parent a8c4676240
commit 994745839b
4 changed files with 9 additions and 9 deletions

View File

@@ -216,7 +216,7 @@ describe "Stats", :admin do
end
context "graphs" do
scenario "event graphs" do
scenario "event graphs", :with_frozen_time do
campaign = create(:campaign)
visit root_path(track_id: campaign.track_id)
@@ -227,9 +227,9 @@ describe "Stats", :admin do
end
expect(page).to have_content "#{campaign.name} (1)"
within("#graph") do
event_created_at = Ahoy::Event.find_by(name: campaign.name).time
expect(page).to have_content event_created_at.strftime("%Y-%m-%d")
expect(page).to have_content Date.current.strftime("%Y-%m-%d")
end
end
end