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
I view the source of the html document, and the hidden field is
What’s the story here?