# Testing multiple page actions in Rails

**URL:** <https://www.ruby-forum.com/t/testing-multiple-page-actions-in-rails/49524>\
**Category:** Ruby\
**Created:** [November 22, 2005, 5:54pm UTC](https://www.ruby-forum.com/t/testing-multiple-page-actions-in-rails/49524 "2005-11-22T17:54:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![listrecv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f17d59/32.png) [@listrecv](https://www.ruby-forum.com/u/listrecv)\
**Post date:** [November 22, 2005, 5:54pm UTC](https://www.ruby-forum.com/t/testing-multiple-page-actions-in-rails/49524/1 "2005-11-22T17:54:40Z")

</div>

Some actions in Rails require sessions spanning multiple pages. Things  
like “login & check account” or “fill a shopping cart and check out”.

I’m having trouble creating functional testing for these for two  
reasons:

1. The post() etc. methods seem to reset the session each time.

2. How do you create a functional test that accesses multiple  
controllers?

Specifically, could someone post a functional test to a controller that  
requires the user be logged in first?

Thanks.

---

<div class="post-metadata">

**Author:** ![listrecv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f17d59/32.png) [@listrecv](https://www.ruby-forum.com/u/listrecv)\
**Post date:** [November 22, 2005, 5:58pm UTC](https://www.ruby-forum.com/t/testing-multiple-page-actions-in-rails/49524/2 "2005-11-22T17:58:42Z")

</div>

removed\_email\_address@domain.invalid wrote:

> 1. How do you create a functional test that accesses multiple  
> controllers?
> 
> Specifically, could someone post a functional test to a controller that  
> requires the user be logged in first?
> 
> Thanks.

You might have better results posting this to the Rails mailing list at

[http://lists.rubyonrails.org/mailman/listinfo](http://lists.rubyonrails.org/mailman/listinfo).

---

<div class="post-metadata">

**Author:** ![listrecv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f17d59/32.png) [@listrecv](https://www.ruby-forum.com/u/listrecv)\
**Post date:** [November 22, 2005, 7:51pm UTC](https://www.ruby-forum.com/t/testing-multiple-page-actions-in-rails/49524/3 "2005-11-22T19:51:30Z")

</div>

I took a look at some RoR projects, to see how they do this.

Many just set the session explicilty, to simulate what it would look  
like in the middle.

I don’t like this, because it couples the test to the implementation of  
what’s stored in the session. It would be much better to have a tester  
that can span multiple requests.
