# Is it possible to follow redirects outside of Rails on an integration test?

**URL:** <https://www.ruby-forum.com/t/is-it-possible-to-follow-redirects-outside-of-rails-on-an-integration-test/176336>\
**Category:** Rails\
**Created:** [September 29, 2009, 9:19am UTC](https://www.ruby-forum.com/t/is-it-possible-to-follow-redirects-outside-of-rails-on-an-integration-test/176336 "2009-09-29T09:19:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JSPablo\_FernSSSSnd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e9bcb4/32.png) [@JSPablo\_FernSSSSnd](https://www.ruby-forum.com/u/JSPablo_FernSSSSnd)\
**Post date:** [September 29, 2009, 9:19am UTC](https://www.ruby-forum.com/t/is-it-possible-to-follow-redirects-outside-of-rails-on-an-integration-test/176336/1 "2009-09-29T09:19:43Z")

</div>

Hello,  
Is it possible to follow redirects outside of Rails on an integration  
test?

I’m trying to test my whole log in procedure and part of it includes  
authenticating with OpenID. I have rots running locally but when I’m  
suppose  
do be redirected to the localhost:1123/server (the rots server) I end up  
being redirected to localhost:3000/server (the rails server with an url  
that  
doesn’t exist). It is like if the code that follows the redirection on  
integration tests is ignoring the URL. Is there any way to enable  
external  
redirections?

## Thanks.

J. Pablo FernÃ¡ndez [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) ([http://pupeno.com](http://pupeno.com))

---

<div class="post-metadata">

**Author:** ![JSPablo\_FernSSSSnd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e9bcb4/32.png) [@JSPablo\_FernSSSSnd](https://www.ruby-forum.com/u/JSPablo_FernSSSSnd)\
**Post date:** [September 30, 2009, 2:11pm UTC](https://www.ruby-forum.com/t/is-it-possible-to-follow-redirects-outside-of-rails-on-an-integration-test/176336/2 "2009-09-30T14:11:37Z")

</div>

Hello Bill,  
Thanks for the reply. As far as I know the full URL is being used for  
the  
redirect. I remember seeing the url in the debugger and also, the URL is  
being generated by ruby-openid, so if it wasn’t using the full URL,  
ruby-openid would be broken for everybody.

I can’t check it right now, as soon as I can I’ll do it and post the  
result.

Thanks.

On Tue, Sep 29, 2009 at 21:43, bill walton [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> (‘[http://localhost:1123/server](http://localhost:1123/server)’) in your redirect?
> 
> Best regards,  
> Bill
> 
> >

–  
J. Pablo FernÃ¡ndez [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) ([http://pupeno.com](http://pupeno.com))

---

<div class="post-metadata">

**Author:** ![JSPablo\_FernSSSSnd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e9bcb4/32.png) [@JSPablo\_FernSSSSnd](https://www.ruby-forum.com/u/JSPablo_FernSSSSnd)\
**Post date:** [September 29, 2009, 9:43pm UTC](https://www.ruby-forum.com/t/is-it-possible-to-follow-redirects-outside-of-rails-on-an-integration-test/176336/3 "2009-09-29T21:43:23Z")

</div>

Hi Pablo,

On Tue, 2009-09-29 at 08:02 +0200, J. Pablo FernÃ¡ndez wrote:

> server) I end up being redirected to localhost:3000/server (the rails  
> server with an url that doesn’t exist). It is like if the code that  
> follows the redirection on integration tests is ignoring the URL. Is  
> there any way to enable external redirections?

I haven’t tested this, but are you using the fully qualified url  
(‘[http://localhost:1123/server](http://localhost:1123/server)’) in your redirect?

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![JSPablo\_FernSSSSnd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e9bcb4/32.png) [@JSPablo\_FernSSSSnd](https://www.ruby-forum.com/u/JSPablo_FernSSSSnd)\
**Post date:** [September 30, 2009, 8:30pm UTC](https://www.ruby-forum.com/t/is-it-possible-to-follow-redirects-outside-of-rails-on-an-integration-test/176336/4 "2009-09-30T20:30:29Z")

</div>

Confirmed that it doesn’t work, this is the test:

# Replace this with your real tests.

test “log in” do  
# Submit open id identifier to log in.  
post “/users/start”, :openid\_identifier =\> "  
[http://localhost:1123/john.doe?openid.success=true](http://localhost:1123/john.doe?openid.success=true)"  
# We get redirected to the authentication page at the OpenID  
provider  
assert redirect?  
# which is on [http://localhost:1123/server](http://localhost:1123/server).  
assert @response.redirected\_to.start\_with?  
“[http://localhost:1123/server](http://localhost:1123/server)  
"  
# Go.  
follow\_redirect!  
# The OpenID server automatically approves any request, it’s a test  
server  
# called rots, it should redirect us back to the application  
assert redirect?  
# to [http://localhost:3000/users/complete](http://localhost:3000/users/complete)  
assert @response.redirected\_to.start\_with? "  
[http://localhost:3000/users/complete](http://localhost:3000/users/complete)”  
end

At the second assert redirect? in which the OpenID server should be  
redirecting me back, I get a failure. If I look at the logs, the OpenID  
server, running on port 1123 never gets a request, while the Rails  
server  
running on 3000 get’s a request to the path the OpenID server was  
supposed  
to get the request for: /server/…

Thanks.

2009/9/30 J. Pablo FernÃ¡ndez [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> > > test?
> 
> –  
> J. Pablo FernÃ¡ndez [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) ([http://pupeno.com](http://pupeno.com))

–  
J. Pablo FernÃ¡ndez [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) ([http://pupeno.com](http://pupeno.com))
