Test
def test_generateCashFlowStmt
get :getDateRangeForCashFlowStmt
xhr :post,
:generate_cash_flow_stmt,
{:fromDate => {:year=>"2009", :month => "3", :day=>"1"},
:toDate => {:year=>"2009", :month => "3", :day=>"31"} }
table = [ .... ]
assert_equal table, formatCashFlowStatementAsTable( assigns(:cashFlowStmt))
assert_tag :tag => "div", :children => {:count => 1, :only => {:tag=>"table"} }
end
Controller Action
def generate_cash_flow_stmt
puts params
fromDate = Date.civil params[:fromDate]["year"].to_i, params[:fromDate]["month"].to_i, params[:fromDate]["day"].to_i
toDate = Date.civil params[:toDate]["year"].to_i, params[:toDate]["month"].to_i, params[:toDate]["day"].to_i
@cashFlowStmt = CashFlowStatement.new(fromDate, toDate)
render :partial => "cash_flow_stmt", :layout => false
end
View
<% form_remote_tag(:loading => "Element.show('progress-indicator');",
:update => "div_results",
:complete => "Element.hide('progress-indicator');",
:url=>{:action=>'generate_cash_flow_stmt'}) do %>
...
<% end %>
<div id="div_results">
The test fails at the last check, where I check if the div content holder is populated with the table as a result of the call to generate_cash_flow_stmt access. Although I see the table being displayed in the browser, the 'View Source' action shows a blank div tag. What gives?