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 104931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:21:33+00:00 2026-05-11T01:21:33+00:00

In my Rails app, I have a form which redirects through a foreign service,

  • 0

In my Rails app, I have a form which redirects through a foreign service, Amazon FPS. The form POSTs to an action in my app which redirects to Amazon, who collect information and then redirect back to my app.

I’m testing this workflow with Webrat. Obviously I can’t test Amazon, so I want to check that the redirection to Amazon happens and then simulate Amazon’s redirection back into my app, effectively mocking out Amazon from the test.

However, when Webrat submits the form, it calls ActionController::Integration::Session#request_via_redirect, which follows all redirections until it gets a response which is not a redirect. This includes the redirect to Amazon. Rails ignores the domain and requests the path from the local app, which fails.

What I’m looking for is a way to stop Webrat/Rails from making requests for URLs on other domains and allowing me to verify the redirection.

  • 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. 2026-05-11T01:21:34+00:00Added an answer on May 11, 2026 at 1:21 am

    Solution: make my own way.

    class ActionController::Integration::Session   # Intercepts a request to a foreign domain.  Use this to stub   # a service which the user is bounced through, such as an   # OpenID provider.  The block should return a new URL to   # request.  This is the URL which the foreign service would   # redirect the browser to if we were really using it.   #    # Currently, the return URL can only be requested with a GET.   #    #   stub_request 'foreign.host.com' do |path|   #     return_from_bounce_url   #   end   def stub_request(host, &block)     @request_stubs ||= {}     @request_stubs[host] = block   end    def process_with_stubs(method, path, parameters = nil, headers = nil)     @request_stubs ||= {}      if @request_stubs.key? self.host       url = @request_stubs[host].call(path)       process_without_stubs(method, url, parameters, headers)     else       process_without_stubs(method, path, parameters, headers)     end   end   alias_method_chain :process, :stubs end 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 77k
  • Answers 77k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer On Linux it surely is possible by accessing /dev/ files.… May 11, 2026 at 3:36 pm
  • added an answer I wouldn't perform the the encryption as part of the… May 11, 2026 at 3:36 pm
  • added an answer At compile time no. At runtime you could validate this… May 11, 2026 at 3:36 pm

Related Questions

I have some data that I want to store somewhere in my Rails app
I have a rails app that has picked up a bit of traction, but
I'm pretty new to Rails and have an issue which I can't quite get
I have two forms in my rails app. They both exist in separate tabs

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.