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:
- 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>
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
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). 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
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). 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