Use a block to travel in time in specs

If we don't use a block, if the spec fails the `travel_back` method
isn't executed.
This commit is contained in:
Javi Martín
2019-10-24 19:24:22 +02:00
parent 00145d54ca
commit aac23ea596

View File

@@ -420,17 +420,15 @@ describe "Proposal Notifications" do
expect(page).to have_content "Your message has been sent correctly." expect(page).to have_content "Your message has been sent correctly."
travel 3.days + 1.second travel(3.days + 1.second) do
visit new_proposal_notification_path(proposal_id: proposal.id)
fill_in "Title", with: "Thank you again for supporting my proposal"
fill_in "Message", with: "Please share it again with others so we can make it happen!"
click_button "Send message"
visit new_proposal_notification_path(proposal_id: proposal.id) expect(page).to have_content "Your message has been sent correctly."
fill_in "Title", with: "Thank you again for supporting my proposal" expect(page).not_to have_content "You have to wait a minimum of 3 days between notifications"
fill_in "Message", with: "Please share it again with others so we can make it happen!" end
click_button "Send message"
expect(page).to have_content "Your message has been sent correctly."
expect(page).not_to have_content "You have to wait a minimum of 3 days between notifications"
travel_back
end end
end end
end end