Thanks for the quick response Phil. That fixed the problem. But now I have a different issue.
When login is complete, control is redirected to another page. That page submits a background job to Sidekiq and then displays a screen with a META refresh of 15 seconds. When running live, this makes the page refresh every 15 seconds. Once the report has finished, the controller recognizes this and instead of generating the holding page, generates the report. That’s how it works in development and production. In testing, there is no background job. So instead, I added a call inline within the test to run the background job. It works just fine, but the browser display never refreshes. And if I click the Refresh button on the browser screen, it acts like it’s doing something (dot running back and forth on tab’s header) but never finishes. And if I try “page.driver.refresh” (instead of clicking the page’s refresh button), nothing happens (no refresh, no running dot, etc). I can accept that maybe the META Refresh is being ignored, but I would have though that page.driver.refresh would have refreshed the page, and that if that didn’t, then the refresh button would. If I change the post-login action to redirect to a different page with no META refresh, it works just fine. > On Nov 19, 2020, at 12:34 AM, Phil Pirozhkov <[email protected]> wrote: > > Before you got it to Rails 5.1, you'll have to share the transaction to be > able to set up the database from "the client part". > https://test-prof.evilmartians.io/#/recipes/active_record_shared_connection > <https://test-prof.evilmartians.io/#/recipes/active_record_shared_connection> > On Thu, Nov 19, 2020 at 6:27 AM Jack Royal-Gordon <[email protected] > <mailto:[email protected]>> wrote: > Testing a Rails app (4.2) with RSpec (3.99) and Capybara (2.18). The > beginning of the test creates a user and attempts to login to the user's > account. By the time my Rails code gets control in the "login" module, the > user has disappeared from the database. Here's the code in question: > > @user = FactoryGirl.create :user_fully_setup > visit root_path > fill_in :email, with: @user.email > fill_in :password, with: @user.password > click_button > > This code executes successfully (the click_button logs in the user) unless I > add “js: true” to the test example, in which case I can see the browser > window and it indeed fails to login (because the user is gone). > > When running with Selenium, at the point before "click_button", the user > still exists. When it hits my first "before_filter" in the controller when > the "click_button" is executed, the user is gone (along with records in other > tables created at the same time as the user). > > I know that RSpec often runs inside a db transaction, is there any way > Capybara could be causing the transaction to get reset? > > If you’re wondering why I’m trying to run this with Selenium when it works > just fine without it, it’s really just the first step of the test, and JS is > being tested downstream from this part, so I will need it, just not for this > part. > > -- > You received this message because you are subscribed to the Google Groups > "rspec" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rspec/2D73D42B-CC1B-41E6-BFEE-EDECADEE128F%40pobox.com > > <https://groups.google.com/d/msgid/rspec/2D73D42B-CC1B-41E6-BFEE-EDECADEE128F%40pobox.com?utm_medium=email&utm_source=footer>. > > -- > You received this message because you are subscribed to the Google Groups > "rspec" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rspec/CAAk5Ok-Wv1F7Ae6f5zG%2B%2BTMr5_Jaas3Rt0E17N_igmW5PrGFqw%40mail.gmail.com > > <https://groups.google.com/d/msgid/rspec/CAAk5Ok-Wv1F7Ae6f5zG%2B%2BTMr5_Jaas3Rt0E17N_igmW5PrGFqw%40mail.gmail.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "rspec" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/8D893EB0-9465-4585-8CA6-7EE35912A509%40pobox.com.
