# Functional testing issue

**URL:** <https://www.ruby-forum.com/t/functional-testing-issue/48420>\
**Category:** Rails\
**Created:** [November 20, 2005, 4:08am UTC](https://www.ruby-forum.com/t/functional-testing-issue/48420 "2005-11-20T04:08:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mithill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mithill](https://www.ruby-forum.com/u/mithill)\
**Post date:** [November 20, 2005, 4:08am UTC](https://www.ruby-forum.com/t/functional-testing-issue/48420/1 "2005-11-20T04:08:36Z")

</div>

This is a really basic test, but the rails test environment does not  
give me the results I expect. Hopefully someone can set me straight.

I send in a get request with one parameter and the application opens a  
page to edit this object - fairly basic. On this edit view there is a  
hidden field that contains the id value of the object. When I do this in  
the “real” application and view the source of the rendered html page,  
everything is as expected. However, when I do the same request through  
the functional test, the hidden input tag is created but the value  
attribute is not set. This is confirmed with an assert\_tag statement and  
by visual inspection of the result of “puts @response.body”.

To head off the obvious, I have double checked that the appropriate  
fixtures are loaded, that the object with the id I specify is in the  
test database and that I am specifying the correct id.

The test database has an event with id = 1 and my dev database has an  
event with an id = 5

Here is the call to “get” in the test. @session\_admin is just a session  
hash I’ve set up to have the administrator logged on.

get(:show, {‘event[id]’ =\> ‘1’}, @session\_admin)  
puts @response.body

When I look at the output, the hidden field shows up but it has no value  
attribute, as follows:

The hidden field is defined in the view as follows:

\<%= hidden\_field(‘event’,‘id’) %\>

Now, I use the following URL while running the application logged on as  
the administrator:  
[http://localhost:3000/events/show?event[id]=5](http://localhost:3000/events/show?event%5Bid%5D=5)

I view the source of the html document, and the hidden field is

What’s the story here?

---

<div class="post-metadata">

**Author:** ![mithill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mithill](https://www.ruby-forum.com/u/mithill)\
**Post date:** [November 20, 2005, 4:16am UTC](https://www.ruby-forum.com/t/functional-testing-issue/48420/2 "2005-11-20T04:16:40Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

On Nov 19, 2005, at 7:06 PM, Matthew T. wrote:

> get(:show, {‘event[id]’ =\> ‘1’}, @session\_admin)

See whether this helps:  
get :show, {‘event’ =\> { ‘id’ =\> ‘1’ }}, @session\_admin

Not sure about the source of the discrepancy you’re seeing.

jeremy  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.2 (Darwin)

iD8DBQFDf+mzAQHALep9HFYRAqHOAJ4syIcPhssymZZ0eWwaHwunCqlDrwCghD9W  
dU45ICz7gNVIS/BsEuKHuTc=  
=RJLj  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![mithill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mithill](https://www.ruby-forum.com/u/mithill)\
**Post date:** [November 20, 2005, 4:28am UTC](https://www.ruby-forum.com/t/functional-testing-issue/48420/3 "2005-11-20T04:28:43Z")

</div>

On Nov 19, 2005, at 8:06 PM, Matthew T. wrote:

> is created but the value attribute is not set. This is confirmed  
> Here is the call to “get” in the test. @session\_admin is just a  
> session hash I’ve set up to have the administrator logged on.
> 
> get(:show, {‘event[id]’ =\> ‘1’}, @session\_admin)  
> puts @response.body

In functional tests, the parameters are not parsed. You need to pass  
in the hash that the parameters will be converted to:

get :show, {:event =\> { :id =\> ‘1’ }}, @session\_admin

- Jamis

---

<div class="post-metadata">

**Author:** ![mithill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mithill](https://www.ruby-forum.com/u/mithill)\
**Post date:** [November 20, 2005, 5:41pm UTC](https://www.ruby-forum.com/t/functional-testing-issue/48420/4 "2005-11-20T17:41:57Z")

</div>

That was it, thank you for the replies Jeremy and Jamis.
