Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8616311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:35:17+00:00 2026-06-12T05:35:17+00:00

When a user goes to /auth/facebook , it gets redirected to FB, then back

  • 0

When a user goes to /auth/facebook, it gets redirected to FB, then back to my /auth/facebook/callback if successful.

How can I write an RSpec test that will follow all of these redirects to verify my user has been authenticated?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:35:18+00:00Added an answer on June 12, 2026 at 5:35 am

    I would recommend an alternative, simpler approach.
    What if you tested callback controller directly to see how it reacts to different values passed to it in the omniauth.auth or if env[“omniauth.auth”] is missing or incorrect. Following redirects would be equivalent of testing omniauth plugin, which does not test YOUR system.

    For example, here is what we have in our tests (this is just a few examples, we have many more that verify other variations of omniauth hash and user state prior to sign-in attempt, such as invitation status, user account being disabled by the admins, etc.):

    describe Users::OmniauthCallbacksController do
      before :each do
        # This a Devise specific thing for functional tests. See https://github.com/plataformatec/devise/issues/608
        request.env["devise.mapping"] = Devise.mappings[:user]
      end
      describe ".create" do
    
        it "should redirect back to sign_up page with an error when omniauth.auth is missing" do
          @controller.stub!(:env).and_return({"some_other_key" => "some_other_value"})
          get :facebook
          flash[:error].should be
          flash[:error].should match /Unexpected response from Facebook\./
          response.should redirect_to new_user_registration_url
        end
    
        it "should redirect back to sign_up page with an error when provider is missing" do
          stub_env_for_omniauth(nil)
          get :facebook
          flash[:error].should be
          flash[:error].should match /Unexpected response from Facebook: Provider information is missing/
          response.should redirect_to new_user_registration_url
        end
      end
    end
    

    with stub_env_for_omniauth method defined as follows:

    def stub_env_for_omniauth(provider = "facebook", uid = "1234567", email = "bob@contoso.com", name = "John Doe")
      env = { "omniauth.auth" => { "provider" => provider, "uid" => uid, "info" => { "email" => email, "name" => name } } }
      @controller.stub!(:env).and_return(env)
      env
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want a facility that if user login then goes to home/index i not
I want to setup a route so that if the user goes to http://mysite.com/page.html
I have web pages that are endless pages -- i.e. if the user goes
Imagine the following: User goes to script ( http://sample.org/test.php ), Script sends an HTTP
For example, if an user is on http://example.com , then the user goes to
Use Case When a user goes to my website, they will be confronted with
I have some activity were user goes through it and finally send the selected
This is a question best illustrated by example: User goes to Site A ,
I'm having troubles with fckeditor in Firefox. When the user goes to a page,
I've got the Silverlight app with 4 pages(wizard). Usually user goes throught these 4

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.