Hello,
This is the test code. Over here i am trying to test the partial, is
it render or not?
I tried to test it with assert_tag, but its giving me an error and
the whole dump of th partial.
I have never tested partial. So if any body has test partial, please
help me with this
def test_update_cloud
get :update_cloud
assert_response(:success)
assert_tag :tag => ‘span’,attributes => { :id => “notification” }
end
This is the controller code I went to test.
def update_cloud
cloud
render :partial => “/shared/cloud”
end
This is the small piece of parial code called ‘cloud’ it’s in shared
directory
100 Highlight level? <%= select_tag ‘num_gray[]’,
101 options_for_select({ ‘least (’+@num_size_one.to_s+’)’ => 1,
‘less (’+@num_size_two.to_s+’)’ => 2, ‘average (’+@num_size_three.to_s
+’)’ => 3, ‘more (’+@num_size_four.to_s+’)’ => 4, ‘most
(’+@num_size_five.to_s+’)’=> 5}.sort{|a,b| a[1]<=>b[1]},
@num_gray), :onchange =>
‘changeColor(this.options[this.selectedIndex].value)’ %>
102
103
104 <%= @link2 %>
This is the cloud method, not really relevent here.
def cloud
# tag_id is in both triples and events tables. which one?
# ajax feature to choose how many tags are going to be gray
@num_gray = params[:num_gray] ? params[:num_gray].to_i : 1
logger.debug ’ num_gray = %s ’ % @num_gray
@total = 0 #number of all tag_id
@size_tag = Hash.new
@distinct_triples = Triple.find_by_sql("select distinct tag_id
from triples")
logger.debug ’ distinct_triples = %s ’ % @distinct_triples
@distinct_triples.each do |t|
if(!t.tag.nil? && !t.tag.name.empty?) then
@size_tag[t.tag_id] = Triple.find(:all, :condition
[ “tag_i= ?”,t.tag_id ]).size
@total += @size_tag[t.tag_id]
end
Thanks