# Weird Functional Test Behavior

**URL:** <https://www.ruby-forum.com/t/weird-functional-test-behavior/129935>\
**Category:** Rails\
**Created:** [February 22, 2008, 9:28pm UTC](https://www.ruby-forum.com/t/weird-functional-test-behavior/129935 "2008-02-22T21:28:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkanders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@dkanders](https://www.ruby-forum.com/u/dkanders)\
**Post date:** [February 22, 2008, 9:28pm UTC](https://www.ruby-forum.com/t/weird-functional-test-behavior/129935/1 "2008-02-22T21:28:09Z")

</div>

Hi All,

I have a test that is failing and I can’t figure it out… it fails the  
first time in autotest and the second time it runs (once autotest is  
started), the test doesn’t fail.

Thanks in advance for your help. Here is the test file:

#################TEST FILE############

require File.dirname( **FILE** ) + ‘/…/…/test\_helper’

class Admin::StoriesControllerTest \< ActionController::TestCase  
def first\_story\_form\_attributes  
s = stories(:one).attributes  
s.delete(“updated\_at”)  
s.delete(“created\_at”)  
s.delete(“id”)  
s  
end

def test\_should\_not\_update\_story\_admin  
old\_attributes = first\_story\_form\_attributes  
old\_attributes[:headline] = “”  
post :update, {:id =\> stories(:one).id, :record =\> old\_attributes}  
assert\_response :success #THIS IS LINE 46  
assert\_select “div#errorExplanation” do  
assert\_select “li”, :text =\> /Headline/  
end  
end  
end  
###END TEST FILE#####

####ERROR REPORTED:##### Here is the error:

1. Failure:  
test\_should\_not\_update\_story\_admin(Admin::StoriesControllerTest)  
[./test/functional/admin/stories\_controller\_test.rb:46:in  
`test_should_not_update_story_admin' /Users/danderson/Projects/my_project/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/testing/default.rb:7:in`run’]:  
Expected response to be a \<:success\>, but was \<302\>

---

<div class="post-metadata">

**Author:** ![dkanders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@dkanders](https://www.ruby-forum.com/u/dkanders)\
**Post date:** [February 22, 2008, 10:57pm UTC](https://www.ruby-forum.com/t/weird-functional-test-behavior/129935/2 "2008-02-22T22:57:33Z")

</div>

Dustin A. wrote:

> Expected response to be a \<:success\>, but was \<302\>

Can you show us your controller code handling the action as it appears  
that you are redirecting the response

ilan

---

<div class="post-metadata">

**Author:** ![dkanders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@dkanders](https://www.ruby-forum.com/u/dkanders)\
**Post date:** [February 25, 2008, 3:21pm UTC](https://www.ruby-forum.com/t/weird-functional-test-behavior/129935/3 "2008-02-25T15:21:20Z")

</div>

Ilan B. wrote:

> Dustin A. wrote:
> 
> > Expected response to be a \<:success\>, but was \<302\>
> 
> Can you show us your controller code handling the action as it appears  
> that you are redirecting the response
> 
> ilan

Thanks Ilan,

Unfortunately, my controller is an Active Scaffold controller  
([www.activescaffold.com](http://www.activescaffold.com)). So, there isn’t much to it:

class Admin::StoriesController \< ApplicationController  
layout ‘admin’  
active\_scaffold :story do |config|  
config.create.link.page = true  
config.update.link.page = true  
config.create.multipart = true  
config.update.multipart = true  
config.list.columns = [ :date, :headline, :author, :state, :country,  
:is\_published ]  
end

end

---

<div class="post-metadata">

**Author:** ![dkanders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@dkanders](https://www.ruby-forum.com/u/dkanders)\
**Post date:** [February 26, 2008, 5:10am UTC](https://www.ruby-forum.com/t/weird-functional-test-behavior/129935/4 "2008-02-26T05:10:25Z")

</div>

Dustin A. wrote:

> Ilan B. wrote:
> 
> > Dustin A. wrote:
> > 
> > > Expected response to be a \<:success\>, but was \<302\>
> > 
> > Can you show us your controller code handling the action as it appears  
> > that you are redirecting the response
> > 
> > ilan
> 
> Thanks Ilan,
> 
> Unfortunately, my controller is an Active Scaffold controller  
> ([www.activescaffold.com](http://www.activescaffold.com)). So, there isn’t much to it:
> 
> class Admin::StoriesController \< ApplicationController  
> layout ‘admin’  
> active\_scaffold :story do |config|  
> config.create.link.page = true  
> config.update.link.page = true  
> config.create.multipart = true  
> config.update.multipart = true  
> config.list.columns = [ :date, :headline, :author, :state, :country,  
> :is\_published ]  
> end
> 
> end

Sorry, not much experience with scaffolding as I believe that it is next  
to useless and only hampers you from getting your hands dirty and  
figuring out the details of how rails handles MVC.

ilan
