Update travel_to usage

In Rails 5.1, calling `travel_to` inside another `travel_to` block will
result in a RuntimeError:

> Calling `travel_to` with a block, when we have previously already made
> a call to `travel_to`, can lead to confusing time stubbing.
This commit is contained in:
Javi Martín
2019-04-29 11:58:25 +02:00
parent 307cf24846
commit db6ed4772c
2 changed files with 9 additions and 11 deletions

View File

@@ -187,13 +187,10 @@ describe "Voter" do
expect(page).not_to have_link(answer_yes.title) expect(page).not_to have_link(answer_yes.title)
end end
travel_back
click_link "Sign out" click_link "Sign out"
# Time needs to pass between the moment we vote and the moment
# we log in; otherwise the link to vote won't be available.
# It's safe to advance one second because this test isn't
# affected by possible date changes.
travel 1.second do
login_as user login_as user
visit poll_path(poll) visit poll_path(poll)
@@ -203,7 +200,6 @@ describe "Voter" do
end end
end end
end end
end
scenario "Voting in poll and then verifiying account", :js do scenario "Voting in poll and then verifiying account", :js do
user = create(:user) user = create(:user)

View File

@@ -271,6 +271,8 @@ describe Poll::Stats do
expect(stats.version).to eq "v#{time.to_i}" expect(stats.version).to eq "v#{time.to_i}"
travel_back
travel_to 2.seconds.from_now do travel_to 2.seconds.from_now do
expect(stats.version).to eq "v#{time.to_i}" expect(stats.version).to eq "v#{time.to_i}"
end end