mdarby-pollster 0.1.2.1 → 0.1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,5 +5,20 @@ module <%= class_name.pluralize %>Helper
|
|
5
5
|
page.insert_html :bottom, :options, :partial => 'option_form', :locals => {:option => []}
|
6
6
|
end
|
7
7
|
end
|
8
|
+
|
9
|
+
def display_graph(<%= object_name %>, options = {})
|
10
|
+
size = options.has_key?(:size) ? options[:size] : "350x150"
|
11
|
+
base_color = options.has_key?(:base_color) ? options[:base_color] : "2F87ED"
|
12
|
+
bg_color = options.has_key?(:bg_color) ? options[:bg_color] : "EEEEEE"
|
13
|
+
|
14
|
+
Gchart.pie_3d(
|
15
|
+
:size => size,
|
16
|
+
:bar_colors => base_color,
|
17
|
+
:bg => bg_color,
|
18
|
+
:legend => <%= object_name %>.pie_legend,
|
19
|
+
:data => <%= object_name %>.current_results_percentages,
|
20
|
+
:format => 'image_tag'
|
21
|
+
)
|
22
|
+
end
|
8
23
|
|
9
24
|
end
|
@@ -1,10 +1,25 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
|
+
module <%= class_name %>Attributes
|
4
|
+
def valid_attributes
|
5
|
+
{
|
6
|
+
:name => "foo",
|
7
|
+
:description => "foo",
|
8
|
+
:options => ["first", "second", "third"],
|
9
|
+
:ends_at => Date.parse("2009-01-09"),
|
10
|
+
:created_at => Date.parse("2009-01-01"),
|
11
|
+
:updated_at => Date.parse("2009-01-01"),
|
12
|
+
:created_by_id => 1
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
3
17
|
describe <%= class_name %>sHelper do
|
4
18
|
|
19
|
+
include <%= class_name %>Attributes
|
20
|
+
|
5
21
|
describe " -- add_option_link" do
|
6
22
|
it "should provide a link that inserts a new option" do
|
7
|
-
pending("This is passing, but needs RJS love")
|
8
23
|
<%= object_name %> = mock_model(<%= class_name %>)
|
9
24
|
|
10
25
|
page = mock(page, :insert_html => self)
|
@@ -14,4 +29,43 @@ describe <%= class_name %>sHelper do
|
|
14
29
|
end
|
15
30
|
end
|
16
31
|
|
32
|
+
describe " -- display_graph" do
|
33
|
+
before do
|
34
|
+
@<%= object_name %> = <%= class_name %>.create!(valid_attributes)
|
35
|
+
end
|
36
|
+
|
37
|
+
describe " accepted parameters" do
|
38
|
+
it "should accept a :size parameter" do
|
39
|
+
helper.display_graph(@<%= object_name %>, :size => "100x150").should include_text 'width="100" height="150"'
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should accept a :base_color parameter" do
|
43
|
+
helper.display_graph(@<%= object_name %>, :base_color => "EFEFEF").should include_text 'chco=EFEFEF'
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should accept a :bg_color parameter" do
|
47
|
+
helper.display_graph(@<%= object_name %>, :bg_color => "AFAFAF").should include_text 'chf=bg,s,AFAFAF'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe " default parameters" do
|
52
|
+
before do
|
53
|
+
@<%= object_name %> = <%= class_name %>.create!(valid_attributes)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should accept a :size parameter" do
|
57
|
+
helper.display_graph(@<%= object_name %>).should include_text 'width="350" height="150"'
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should accept a :base_color parameter" do
|
61
|
+
helper.display_graph(@<%= object_name %>).should include_text 'chco=2F87ED'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should accept a :bg_color parameter" do
|
65
|
+
helper.display_graph(@<%= object_name %>).should include_text 'chf=bg,s,EEEEEE'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
17
71
|
end
|
@@ -16,6 +16,7 @@
|
|
16
16
|
<%% end %>
|
17
17
|
</ol>
|
18
18
|
|
19
|
-
<center>
|
20
|
-
|
19
|
+
<center>
|
20
|
+
<%%# The options passed here represent all those that are accepted to modify your graph %>
|
21
|
+
<%%= display_graph(<%= object_name %>, :size => "350x150", :base_color => "2F87ED", :bg_color => "EEEEEE") %>
|
21
22
|
</center>
|