Permalink
Browse files

added a test for the funnel widget, tweaked how it works slightly

  • Loading branch information...
ejdraper committed Apr 16, 2011
1 parent ec710a3 commit f157dab7698eb3ca97fc9128ef4dbb3a3174b930
Showing with 71 additions and 8 deletions.
  1. +8 −8 app/views/widgets/funnel.xml.erb
  2. +20 −0 test/dummy/app/widgets/test_funnel.rb
  3. +43 −0 test/functional/widgets_test.rb
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<% if @data.has_key?(:reverse) %>
- <type>reverse</type>
+ <type>reverse</type>
<% end %>
- <% if @data.has_key?(:percentage) %>
- <percentage>hide</percentage>
+ <% if @data.has_key?(:hide_percentage) %>
+ <percentage>hide</percentage>
<% end %>
- <% @data[:items].each do |key, value| %>
- <item>
- <value><%= value %></value>
- <label><![CDATA[<%= key %>]]></label>
- </item>
+ <% @data[:items].each do |item| %>
+ <item>
+ <value><%= item[:value] %></value>
+ <label><![CDATA[<%= item[:label] %>]]></label>
+ </item>
<% end %>
</root>
@@ -0,0 +1,20 @@
+widget :funnel do
+ key "x"
+ type "funnel"
+ data do
+ {
+ :reverse => true,
+ :hide_percentage => true,
+ :items => [
+ {:value => 87809, :label => "Step 1"},
+ {:value => 70022, :label => "Step 2"},
+ {:value => 63232, :label => "Step 3"},
+ {:value => 53232, :label => "Step 4"},
+ {:value => 32123, :label => "Step 5"},
+ {:value => 23232, :label => "Step 6"},
+ {:value => 12232, :label => "Step 7"},
+ {:value => 2323, :label => "Step 8"}
+ ]
+ }
+ end
+end
@@ -248,4 +248,47 @@ class WidgetsTest < ActionController::TestCase
assert_equal xml, response.body
end
+ test "funnel widget" do
+ get :show, :id => "funnel", :key => "x"
+xml =<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+ <type>reverse</type>
+ <percentage>hide</percentage>
+ <item>
+ <value>87809</value>
+ <label><![CDATA[Step 1]]></label>
+ </item>
+ <item>
+ <value>70022</value>
+ <label><![CDATA[Step 2]]></label>
+ </item>
+ <item>
+ <value>63232</value>
+ <label><![CDATA[Step 3]]></label>
+ </item>
+ <item>
+ <value>53232</value>
+ <label><![CDATA[Step 4]]></label>
+ </item>
+ <item>
+ <value>32123</value>
+ <label><![CDATA[Step 5]]></label>
+ </item>
+ <item>
+ <value>23232</value>
+ <label><![CDATA[Step 6]]></label>
+ </item>
+ <item>
+ <value>12232</value>
+ <label><![CDATA[Step 7]]></label>
+ </item>
+ <item>
+ <value>2323</value>
+ <label><![CDATA[Step 8]]></label>
+ </item>
+</root>
+EOF
+ assert_equal xml, response.body
+ end
end

0 comments on commit f157dab

Please sign in to comment.