goodwill
(goodwill)
June 14, 2008, 9:16am
1
I have a RJS with the following code:
page.replace_html("new_task", :partial=>'task_edit')
page.show("new_task")
page.hide("new_task_link")
Then I try to do a functional test assertion with:
assert_select_rjs :task_has_due_date
which fails and return:
No RJS statement that replaces or inserts HTML content
I am using Rails 2.0.2, any idea?
goodwill
(goodwill)
June 14, 2008, 9:22am
2
To help everyone understand my problem, here is my @response.body
dump:
Element.update("new_task", "\u003Ctr id=\"task\"\u003E\n \u003Ctd
colspan=\"5\"\u003E\n \u003Cform action=\"/tasks\" class=\"new_task\"
id=\"new_task\" method=\"post\" onsubmit=\"new Ajax.Request('/tasks',
{asynchronous:true, evalScripts:true,
parameters:Form.serialize(this)}); return false;\"\u003E\n
\u003Cfieldset\u003E\n \u003Clegend\u003EPlease enter task details
\u003C/legend\u003E\n \u003Cp\u003E\n \u003Clabel for=\"task_priority
\"\u003EPriority\u003C/label\u003E\n \u003Cselect id=\"task_priority
\" name=\"task[priority]\"\u003E\u003Coption value=\"0\"\u003EHigh
\u003C/option\u003E\n\u003Coption value=\"1\" selected=\"selected
\"\u003ENormal\u003C/option\u003E\n\u003Coption value=\"2\"\u003ELow
\u003C/option\u003E\u003C/select\u003E\n \u003C/p\u003E\n \u003Cp
\u003E\n \u003Cinput id=\"task_is_complete\" name=\"task[is_complete]
\" type=\"checkbox\" value=\"1\" /\u003E\u003Cinput name=
\"task[is_complete]\" type=\"hidden\" value=\"0\" /\u003E\n
\u003Clabel for=\"task_is_complete\"\u003ECompleted?\u003C/label\u003E
\n \u003C/p\u003E\n \u003Cp\u003E\n \u003Clabel for=\"task_name
\"\u003ETitle\u003C/label\u003E\n \u003Cinput id=\"task_name\" name=
\"task[name]\" size=\"30\" type=\"text\" /\u003E\n \u003C/p\u003E\n
\u003Cp\u003E\n \u003Cinput id=\"task_has_due_date\" name=
\"task[has_due_date]\" onclick=\"Element.toggle('task_due_date')\"
type=\"checkbox\" value=\"1\" /\u003E\u003Cinput name=
\"task[has_due_date]\" type=\"hidden\" value=\"0\" /\u003E\n
\u003Clabel for=\"task_has_due_date\"\u003EDue Date?\u003C/label\u003E
\n \u003C/p\u003E\n \u003Cp id=\"task_due_date\"\u003E\n
\u003Cselect id=\"task_due_date_1i\" name=\"task[due_date(1i)]\"\u003E
\n\u003Coption value=\"2003\"\u003E2003\u003C/option\u003E\n
\u003Coption value=\"2004\"\u003E2004\u003C/option\u003E\n\u003Coption
value=\"2005\"\u003E2005\u003C/option\u003E\n\u003Coption value=
\"2006\"\u003E2006\u003C/option\u003E\n\u003Coption value=
\"2007\"\u003E2007\u003C/option\u003E\n\u003Coption value=\"2008\"
selected=\"selected\"\u003E2008\u003C/option\u003E\n\u003Coption value=
\"2009\"\u003E2009\u003C/option\u003E\n\u003Coption value=
\"2010\"\u003E2010\u003C/option\u003E\n\u003Coption value=
\"2011\"\u003E2011\u003C/option\u003E\n\u003Coption value=
\"2012\"\u003E2012\u003C/option\u003E\n\u003Coption value=
\"2013\"\u003E2013\u003C/option\u003E\n\u003C/select\u003E\n
\u003Cselect id=\"task_due_date_2i\" name=\"task[due_date(2i)]\"\u003E
\n\u003Coption value=\"1\"\u003EJanuary\u003C/option\u003E\n
\u003Coption value=\"2\"\u003EFebruary\u003C/option\u003E\n
\u003Coption value=\"3\"\u003EMarch\u003C/option\u003E\n\u003Coption
value=\"4\"\u003EApril\u003C/option\u003E\n\u003Coption value=
\"5\"\u003EMay\u003C/option\u003E\n\u003Coption value=\"6\" selected=
\"selected\"\u003EJune\u003C/option\u003E\n\u003Coption value=
\"7\"\u003EJuly\u003C/option\u003E\n\u003Coption value=
\"8\"\u003EAugust\u003C/option\u003E\n\u003Coption value=
\"9\"\u003ESeptember\u003C/option\u003E\n\u003Coption value=
\"10\"\u003EOctober\u003C/option\u003E\n\u003Coption value=
\"11\"\u003ENovember\u003C/option\u003E\n\u003Coption value=
\"12\"\u003EDecember\u003C/option\u003E\n\u003C/select\u003E\n
\u003Cselect id=\"task_due_date_3i\" name=\"task[due_date(3i)]\"\u003E
\n\u003Coption value=\"1\"\u003E1\u003C/option\u003E\n\u003Coption
value=\"2\"\u003E2\u003C/option\u003E\n\u003Coption value=
\"3\"\u003E3\u003C/option\u003E\n\u003Coption value=\"4\"\u003E4\u003C/
option\u003E\n\u003Coption value=\"5\"\u003E5\u003C/option\u003E\n
\u003Coption value=\"6\"\u003E6\u003C/option\u003E\n\u003Coption value=
\"7\"\u003E7\u003C/option\u003E\n\u003Coption value=\"8\"\u003E8\u003C/
option\u003E\n\u003Coption value=\"9\"\u003E9\u003C/option\u003E\n
\u003Coption value=\"10\"\u003E10\u003C/option\u003E\n\u003Coption
value=\"11\"\u003E11\u003C/option\u003E\n\u003Coption value=
\"12\"\u003E12\u003C/option\u003E\n\u003Coption value=
\"13\"\u003E13\u003C/option\u003E\n\u003Coption value=\"14\" selected=
\"selected\"\u003E14\u003C/option\u003E\n\u003Coption value=
\"15\"\u003E15\u003C/option\u003E\n\u003Coption value=
\"16\"\u003E16\u003C/option\u003E\n\u003Coption value=
\"17\"\u003E17\u003C/option\u003E\n\u003Coption value=
\"18\"\u003E18\u003C/option\u003E\n\u003Coption value=
\"19\"\u003E19\u003C/option\u003E\n\u003Coption value=
\"20\"\u003E20\u003C/option\u003E\n\u003Coption value=
\"21\"\u003E21\u003C/option\u003E\n\u003Coption value=
\"22\"\u003E22\u003C/option\u003E\n\u003Coption value=
\"23\"\u003E23\u003C/option\u003E\n\u003Coption value=
\"24\"\u003E24\u003C/option\u003E\n\u003Coption value=
\"25\"\u003E25\u003C/option\u003E\n\u003Coption value=
\"26\"\u003E26\u003C/option\u003E\n\u003Coption value=
\"27\"\u003E27\u003C/option\u003E\n\u003Coption value=
\"28\"\u003E28\u003C/option\u003E\n\u003Coption value=
\"29\"\u003E29\u003C/option\u003E\n\u003Coption value=
\"30\"\u003E30\u003C/option\u003E\n\u003Coption value=
\"31\"\u003E31\u003C/option\u003E\n\u003C/select\u003E\n\n \u003C/p
\u003E\n \u003Cinput id=\"task_submit\" name=\"commit\" type=\"submit
\" value=\"Save\" /\u003E\n \u003Ca href=\"#\" onclick=\"new
Ajax.Request('/tasks/cancel', {asynchronous:true, evalScripts:true,
method:'get'}); return false;\"\u003ECancel\u003C/a\u003E\n \u003C/
fieldset\u003E\n \u003C/form\u003E\n \n \u003C/td\u003E\n\u003C/tr
\u003E");
Element.show("new_task");
Element.hide("new_task_link");
goodwill
(goodwill)
June 14, 2008, 5:44pm
3
Solved.... I have misunderstand how the id parameter is used, it
should be the element involved for the rjs operation. I realize the
issue after drilling source