views:

41

answers:

1

We have a issue on our e-commerce site where users occasionally hit "checkout" twice and have their card charged twice.

It's a common enough bug and easy to fix, but I'd like to test the solution in our capybara setup. Once I've called click_button('checkout'), is it possible for me to pretend I'm a user hitting the browsers back button and then call click_button('checkout') a second time?

A: 

I've used this method in Webrat. I'm sure something similar for Capybara would work.

When(/^I go back$/) do
  visit request.env['HTTP_REFERER']
end

Side note: the "redirect_to :back" method didn't work for me for whatever reason.

Nate Bird
except that will reload the previous page (unlike the browser back button), I'm hoping to just access the source again.
James Healy