How do I test session transfer via custom domains?

11 views
Skip to first unread message

Jeffrey Guenther

unread,
Aug 13, 2016, 1:49:05 AM8/13/16
to rspec
Apologies for the duplicate post. Tab and space all the sudden submit the post rather than indent the code.

Hi rspec community,

I'm developing an app that allows users to set custom domains. We've implemented a form of global id through a technique we've called session trampolines. It's similar to how to Medium has implemented global id for all domains they host. If you're logged into the Medium, you're logged into all the sites it hosts.

We're using Poltergeist as our JS driver.

I have setup testcustomdomain.smartpeoplewritingsomething.info to point to 127.0.0.1 for testing.

When I try to access  testcustomdomain.smartpeoplewritingsomething.info I get an error saying the DNS can't be resolved. I'm not sure what's going on. 

Anyone know how I might structure or configure my tests to use one browser for the entire test?

Here's the test:

require 'rails_helper'

RSpec.feature "custom domain redirects", type: :feature do
  describe "GET to sophia url" do
    it "does not redirect" do
      visit "/"
      expect(page).to have_content("Sign In")
      expect(page.status_code).to equal(200)
    end
  end

  describe "GET custom domain url when signed out" do
    it "tries to transfer session and redirects back to url" do
      page.visit "http://test.lvh.me"
      expect(page).to have_content("Sign In")
      expect(page.status_code).to equal(200)
    end
  end

  describe "GET custom domain url when signed in", js: true do
    it "transfers session and redirects to url" do
      sign_in
      expect(page).to have_content("My Content")

      # This lines gives me an error sayind the DNS can't be resolved.
      # expect(current_url).to eq("http://testcustomdomain.smartpeoplewritingsomething.info/")
      # expect(page).to have_content("Dashboard")
    end
  end
end



Reply all
Reply to author
Forward
0 new messages