|
List Info
Thread: Expected response to be a <:redirect>, but was <200>
|
|
| Expected response to be a
<:redirect>, but was <200> |
  United States |
2007-09-10 17:35:52 |
Greetings, i have a question about a functional test failing
with the
sentence:
Expected response to be a <:redirect>, but was
<200>
The controller's function is
def create
monster = Monster.new(params[:monster])
movement = monster.movements.build(params[:movement])
attack = monster.attacks.build(params[:attack])
if monster.save
flash[:notice] = 'Monster was successfully created.'
redirect_to :action => 'list'
else
render :action => 'new'
end
end
while test is
def test_create
num_monsters = Monster.count
post :create, :monster =>
monsters(:first).attributes
assert_response :redirect
assert_redirected_to :action => 'list'
assert_equal num_monsters + 1, Monster.count
end
by log i see that monster is created but is not directed in
the list
action and i can't understand why ...
may you help me?
ah ... this is my log
Processing AdminController#create (for 0.0.0.0 at 2007-09-11
00:09:09)
[POST]
Session ID:
Parameters: {"action"=>"create",
"monster"=>{"alignment_id"=>1,
"ana_frequency_id"=>1,
"dimension_id"=>1,
"dv_asterischi"=>0,
"salvezza"=>23, "morale"=>3,
"nome"=>"mostro_first",
"numero1"=>"1",
"tesoro"=>nil, "descrizione"=>nil,
"intelligenza"=>2,
"numero2"=>"1",
"id"=>3, "terrain_id"=>1,
"dv"=>2.0, "ca"=>5,
"klass_id"=>1,
"monster_type_id"=>1},
"controller"=>"admin"}
Monster Load (0.001781) SELECT * FROM monsters WHERE
(monsters.nome = 'mostro_first') LIMIT 1
Rendering layoutfalseactionnew within layouts/admin
Rendering admin/new
Dimension Load (0.001151) SELECT * FROM dimensions
AnaMovement Load (0.000953) SELECT * FROM ana_movements
Klass Load (0.000936) SELECT * FROM klasses
Alignment Load (0.001031) SELECT * FROM alignments
MonsterType Load (0.000446) SELECT * FROM monster_types
AnaFrequency Load (0.000436) SELECT * FROM
ana_frequencies
Terrain Load (0.001174) SELECT * FROM terrains
Rendered admin/_form (0.06160)
Completed in 0.09117 (10 reqs/sec) | Rendering: 0.06507
(71%) | DB:
0.01091 (11%) | 200 OK [http://test.host/admin
/create?
monster=alignment_id1salvezza23dv_asterischi0dimension_id1an
a_frequency_id1tesoronumero11nomemostro_firstmorale3numero21
intelligenza2descrizioneterrain_id1id3dv2.0klass_id1ca5monst
er_type_id1]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails" group.
To post to this group, send email to rubyonrails googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-unsubscribe googlegroups.com
For more options, visit this group at http://gro
ups.google.com/group/rubyonrails
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Expected response to be a
<:redirect>, but was <200> |

|
2007-09-10 17:41:27 |
|
| Try adding an error message to your test like:
assert_response :redirect, "Errors on model: #{assigns(:monster).errors.full_messages.to_sentence}"
See if something is awry on your model this way.
James H. On 9/10/07, Valerio Crini
< vcrini gmail.com">vcrini gmail.com> wrote: Greetings, i have a question about a functional test failing with the
sentence:
Expected response to be a <:redirect>, but was <200>
The controller's function is
def create monster = Monster.new(params[:monster]) movement = monster.movements.build
(params[:movement]) attack = monster.attacks.build(params[:attack]) if monster.save flash[:notice] = 'Monster was successfully created.39; redirect_to :action => 'list'
else render :action => 'new39; end end
while test is
def test_create num_monsters = Monster.count
post :create, :monster => monsters(:first).attributes
assert_response :redirect assert_redirected_to :action => 'list'
assert_equal num_monsters + 1, Monster.count end
by log i see that monster is created but is not directed in the list
action and i can't understand why ... may you help me?
ah ... this is my log
Processing AdminController#create (for 0.0.0.0 at 2007-09-11 00:09:09) [POST] Session ID:
Parameters: {"action"=>"create", "monster"=>{"alignment_id"=>1, "ana_frequency_id"=>1, "dimension_id"=>1, "dv_asterischi"=>0,
"salvezza"=>23, "morale"=>3, "nome"=>"mostro_first", "numero1"=>"1", "tesoro"=>nil, "descrizione"=>nil, "intelligenza"=>2, "numero2"=>"1",
"id"=>3, "terrain_id"=>1, "dv"=>2.0, "ca"=>5, "klass_id"=>1, "monster_type_id"=>1}, "controller"=>"admin"} Monster Load (
0.001781) SELECT * FROM monsters WHERE (monsters.nome = 'mostro_first';) LIMIT 1 Rendering layoutfalseactionnew within layouts/admin Rendering admin/new Dimension Load (0.001151) SELECT * FROM dimensions
AnaMovement Load (0.000953) SELECT * FROM ana_movements Klass Load (0.000936) SELECT * FROM klasses Alignment Load (0.001031) SELECT * FROM alignments MonsterType Load (0.000446) SELECT * FROM monster_types
AnaFrequency Load (0.000436) SELECT * FROM ana_frequencies Terrain Load (0.001174) SELECT * FROM terrains Rendered admin/_form (0.06160) Completed in 0.09117 (10 reqs/sec) | Rendering: 0.06507 (71%) | DB:
0.01091 (11%) | 200 OK [http://test.host/admin/create? monster=alignment_id1salvezza23dv_asterischi0dimension_id1ana_frequency_id1tesoronumero11nomemostro_firstmorale3numero21intelligenza2descrizione
terrain_id1id3dv2.0klass_id1ca5monster_type_id1]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails" group. To post to this group, send email to rubyonrails googlegroups.com To unsubscribe from this group, send email to rubyonrails-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails -~----------~----~----~----~------~----~------~--~---
|
| Re: Expected response to be a
<:redirect>, but was <200> |
  United States |
2007-09-11 00:08:49 |
You've solved my problem: with your hint i was able to view
my model's
inconsistency that caused failing of my test.
Thanks a lot
Valerio C
On 11 Set, 00:41, "James Herdman"
<james.herd... gmail.com> wrote:
> Try adding an error message to your test like:
> assert_response :redirect, "Errors on model:
>
#{assigns(:monster).errors.full_messages.to_sentence}"
>
> See if something is awry on your model this way.
>
> James H.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails" group.
To post to this group, send email to rubyonrails googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-unsubscribe googlegroups.com
For more options, visit this group at http://gro
ups.google.com/group/rubyonrails
-~----------~----~----~----~------~----~------~--~---
|
|
[1-3]
|
|