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

View File

@@ -201,7 +201,7 @@ describe "Debates" do
expect(page).to have_content("-6 votes")
end
scenario "Create" do
scenario "Create", :with_frozen_time do
author = create(:user)
login_as(author)
@@ -216,7 +216,7 @@ describe "Debates" do
expect(page).to have_content "Debate created successfully."
expect(page).to have_content "This is very important because..."
expect(page).to have_content author.name
expect(page).to have_content I18n.l(Debate.last.created_at.to_date)
expect(page).to have_content I18n.l(Date.current)
end
scenario "Create with invisible_captcha honeypot field", :no_js do

View File

@@ -4,7 +4,7 @@ describe "Proposals" do
let(:user) { create(:user, :level_two) }
context "Create" do
scenario "Creating proposals on behalf of someone" do
scenario "Creating proposals on behalf of someone", :with_frozen_time do
login_managed_user(user)
login_as_manager
click_link "Create proposal"
@@ -31,7 +31,7 @@ describe "Proposals" do
expect(page).to have_content "This is very important because..."
expect(page).to have_content "https://www.youtube.com/watch?v=yRYFKcMa_Ek"
expect(page).to have_content user.name
expect(page).to have_content I18n.l(Proposal.last.created_at.to_date)
expect(page).to have_content I18n.l(Date.current)
expect(page).to have_current_path(management_proposal_path(Proposal.last))
end

View File

@@ -355,7 +355,7 @@ describe "Proposals" do
expect(page).to have_css "meta[property='og:title'][content=\'#{proposal.title}\']", visible: :hidden
end
scenario "Create and publish" do
scenario "Create and publish", :with_frozen_time do
author = create(:user)
login_as(author)
@@ -387,7 +387,7 @@ describe "Proposals" do
expect(page).to have_content author.name
expect(page).to have_content "Refugees"
expect(page).to have_content "Solidarity"
expect(page).to have_content I18n.l(Proposal.last.created_at.to_date)
expect(page).to have_content I18n.l(Date.current)
end
scenario "Create with invisible_captcha honeypot field", :no_js do