mdarby-pollster 0.1.1
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.
- data/MIT-LICENSE +20 -0
- data/README.textile +37 -0
- data/Rakefile +23 -0
- data/generators/pollster/USAGE +0 -0
- data/generators/pollster/pollster_generator.rb +93 -0
- data/generators/pollster/templates/create_pollster_tables.rb +27 -0
- data/generators/pollster/templates/poll.rb +104 -0
- data/generators/pollster/templates/poll_vote.rb +6 -0
- data/generators/pollster/templates/polls_controller.rb +64 -0
- data/generators/pollster/templates/polls_helper.rb +9 -0
- data/generators/pollster/templates/spec/poll_spec.rb +253 -0
- data/generators/pollster/templates/spec/poll_vote_spec.rb +21 -0
- data/generators/pollster/templates/spec/polls_controller_spec.rb +342 -0
- data/generators/pollster/templates/spec/polls_helper_spec.rb +17 -0
- data/generators/pollster/templates/spec/polls_routing_spec.rb +51 -0
- data/generators/pollster/templates/views/_current_results.html.erb +21 -0
- data/generators/pollster/templates/views/_final_results.html.erb +16 -0
- data/generators/pollster/templates/views/_option_form.html.erb +7 -0
- data/generators/pollster/templates/views/_poll.html.erb +33 -0
- data/generators/pollster/templates/views/_vote.html.erb +11 -0
- data/generators/pollster/templates/views/edit.html.erb +38 -0
- data/generators/pollster/templates/views/index.html.erb +5 -0
- data/generators/pollster/templates/views/new.html.erb +38 -0
- data/init.rb +0 -0
- data/install.rb +1 -0
- data/uninstall.rb +1 -0
- metadata +78 -0
@@ -0,0 +1,342 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe <%= class_name %>sController do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@request.session[:crumbs] = []
|
7
|
+
@request.session[:user_id] = 1
|
8
|
+
current_user = mock_model(User, :display_name => 'Matt Darby')
|
9
|
+
User.stub!(:find => current_user)
|
10
|
+
controller.stub!(:current_user => current_user)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "handling the load_items method" do
|
14
|
+
before do
|
15
|
+
@<%= object_name %> = mock_model(<%= class_name %>)
|
16
|
+
<%= class_name %>.stub!(:find => @<%= object_name %>)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe " with params[:id]" do
|
20
|
+
it "should setup @<%= object_name %>" do
|
21
|
+
get :show, :id => 1
|
22
|
+
assigns[:<%= object_name %>].should == @<%= object_name %>
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe " without params[:id]" do
|
27
|
+
it "should not setup @<%= object_name %>" do
|
28
|
+
<%= class_name %>.stub!(:visible)
|
29
|
+
get :index
|
30
|
+
assigns[:<%= object_name %>].should == nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "handling GET /<%= object_name %>s" do
|
36
|
+
|
37
|
+
before do
|
38
|
+
@<%= object_name %> = mock_model(<%= class_name %>)
|
39
|
+
<%= class_name %>.stub!(:visible).and_return([@<%= object_name %>])
|
40
|
+
end
|
41
|
+
|
42
|
+
def do_get
|
43
|
+
get :index
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should be successful" do
|
47
|
+
do_get
|
48
|
+
response.should be_success
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should render index template" do
|
52
|
+
do_get
|
53
|
+
response.should render_template('index')
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should find all visible <%= object_name %>s" do
|
57
|
+
<%= class_name %>.should_receive(:visible).and_return([@<%= object_name %>])
|
58
|
+
do_get
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should assign the found <%= object_name %>s for the view" do
|
62
|
+
do_get
|
63
|
+
assigns[:<%= object_name %>s].should == [@<%= object_name %>]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "handling GET /<%= object_name %>/1" do
|
68
|
+
it "should redirect to index" do
|
69
|
+
<%= class_name %>.stub!(:find => @<%= object_name %>)
|
70
|
+
get :show, :id => 1
|
71
|
+
response.should redirect_to <%= object_name %>s_path
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "handling GET /<%= object_name %>s/new" do
|
76
|
+
|
77
|
+
before do
|
78
|
+
@<%= object_name %> = mock_model(<%= class_name %>)
|
79
|
+
<%= class_name %>.stub!(:new => @<%= object_name %>)
|
80
|
+
end
|
81
|
+
|
82
|
+
def do_get
|
83
|
+
controller.stub!(:render).with(:partial => 'new', :locals => {:<%= object_name %> => @<%= object_name %>})
|
84
|
+
get :new
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should render new template" do
|
88
|
+
do_get
|
89
|
+
response.should render_template(:new)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should create an new <%= object_name %>" do
|
93
|
+
<%= class_name %>.should_receive(:new).and_return(@<%= object_name %>)
|
94
|
+
do_get
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should not save the new <%= object_name %>" do
|
98
|
+
@<%= object_name %>.should_not_receive(:save)
|
99
|
+
do_get
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should assign the new <%= object_name %> for the view" do
|
103
|
+
do_get
|
104
|
+
assigns[:<%= object_name %>].should equal(@<%= object_name %>)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "handling GET /<%= object_name %>s/1/edit" do
|
109
|
+
|
110
|
+
before do
|
111
|
+
@<%= object_name %> = mock_model(<%= class_name %>)
|
112
|
+
<%= class_name %>.stub!(:find => @<%= object_name %>)
|
113
|
+
end
|
114
|
+
|
115
|
+
def do_get
|
116
|
+
@request.env["HTTP_ACCEPT"] = "text/javascript"
|
117
|
+
controller.stub!(:render).with(:partial => 'edit', :locals => {:<%= object_name %> => @<%= object_name %>})
|
118
|
+
get :edit, :id => 1
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should render edit template" do
|
122
|
+
do_get
|
123
|
+
response.should render_template(:edit)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should find the <%= object_name %> requested" do
|
127
|
+
<%= class_name %>.should_receive(:find).and_return(@<%= object_name %>)
|
128
|
+
do_get
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should assign the found <%= class_name %> for the view" do
|
132
|
+
do_get
|
133
|
+
assigns[:<%= object_name %>].should equal(@<%= object_name %>)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe "handling POST /<%= object_name %>s" do
|
138
|
+
|
139
|
+
before do
|
140
|
+
@<%= object_name %> = mock_model(<%= class_name %>)
|
141
|
+
<%= class_name %>.stub!(:new => @<%= object_name %>)
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "with successful save" do
|
145
|
+
|
146
|
+
def do_post
|
147
|
+
@<%= object_name %>.should_receive(:save).and_return(true)
|
148
|
+
post :create, :<%= object_name %> => {}
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should create a new <%= object_name %>" do
|
152
|
+
<%= class_name %>.should_receive(:new).with({}).and_return(@<%= object_name %>)
|
153
|
+
do_post
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should set a flash message" do
|
157
|
+
do_post
|
158
|
+
flash[:notice].should == "<%= class_name %> successfully created"
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should redirect to the new <%= class_name %>" do
|
162
|
+
do_post
|
163
|
+
response.should redirect_to(<%= object_name %>s_path)
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
describe "with failed save" do
|
169
|
+
|
170
|
+
def do_post
|
171
|
+
@<%= object_name %>.should_receive(:save).and_return(false)
|
172
|
+
post :create, :<%= object_name %> => {}
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should show the error_div with error messages" do
|
176
|
+
do_post
|
177
|
+
response.should render_template(:new)
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe "handling PUT /<%= object_name %>s/1" do
|
184
|
+
|
185
|
+
before do
|
186
|
+
@<%= object_name %> = mock_model(<%= class_name %>)
|
187
|
+
<%= class_name %>.stub!(:find => @<%= object_name %>)
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "with successful update" do
|
191
|
+
|
192
|
+
def do_put
|
193
|
+
@<%= object_name %>.should_receive(:update_attributes).and_return(true)
|
194
|
+
put :update, :id => "1"
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should find the <%= object_name %> requested" do
|
198
|
+
<%= class_name %>.should_receive(:find).with("1").and_return(@<%= object_name %>)
|
199
|
+
do_put
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should update the found <%= object_name %>" do
|
203
|
+
do_put
|
204
|
+
assigns(:<%= object_name %>).should equal(@<%= object_name %>)
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should assign the found <%= object_name %> for the view" do
|
208
|
+
do_put
|
209
|
+
assigns(:<%= object_name %>).should equal(@<%= object_name %>)
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should redirect to the <%= class_name %>" do
|
213
|
+
do_put
|
214
|
+
response.should redirect_to(<%= object_name %>s_path)
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should set a flash message" do
|
218
|
+
do_put
|
219
|
+
flash[:notice].should == "<%= class_name %> was successfully updated."
|
220
|
+
end
|
221
|
+
|
222
|
+
end
|
223
|
+
|
224
|
+
describe "with failed update" do
|
225
|
+
|
226
|
+
def do_put
|
227
|
+
@<%= object_name %>.should_receive(:update_attributes).and_return(false)
|
228
|
+
put :update, :id => "1"
|
229
|
+
end
|
230
|
+
|
231
|
+
it "should set a flash message" do
|
232
|
+
do_put
|
233
|
+
flash[:error].should == "An error occurred"
|
234
|
+
end
|
235
|
+
|
236
|
+
it "should render the edit template" do
|
237
|
+
do_put
|
238
|
+
response.should render_template(:edit)
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
describe "handling DELETE /<%= object_name %>s/1" do
|
245
|
+
|
246
|
+
before do
|
247
|
+
@<%= object_name %> = mock_model(<%= class_name %>, :destroy => true, :save => true)
|
248
|
+
<%= class_name %>.stub!(:find => @<%= object_name %>)
|
249
|
+
end
|
250
|
+
|
251
|
+
def do_delete
|
252
|
+
delete :destroy, :id => "1"
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should find the <%= object_name %> requested" do
|
256
|
+
<%= class_name %>.should_receive(:find).with("1").and_return(@<%= object_name %>)
|
257
|
+
do_delete
|
258
|
+
end
|
259
|
+
|
260
|
+
it "should call destroy on the found <%= object_name %>" do
|
261
|
+
@<%= object_name %>.should_receive(:destroy).and_return(true)
|
262
|
+
do_delete
|
263
|
+
end
|
264
|
+
|
265
|
+
end
|
266
|
+
|
267
|
+
describe "handling POST /<%= object_name %>s/1/vote" do
|
268
|
+
before do
|
269
|
+
@vote = mock_model(<%= class_name %>Vote, :null_object => true)
|
270
|
+
@<%= object_name %> = mock_model(<%= class_name %>, :votes => self)
|
271
|
+
@user = mock_model(User)
|
272
|
+
@<%= object_name %>.votes.stub!(:build => @vote)
|
273
|
+
|
274
|
+
<%= class_name %>.stub!(:find => @<%= object_name %>)
|
275
|
+
controller.stub!(:current_user => @user)
|
276
|
+
end
|
277
|
+
|
278
|
+
describe "with repeat voter" do
|
279
|
+
def do_post
|
280
|
+
post :vote, :id => 1, :<%= object_name %> => {"vote" => "first"}
|
281
|
+
end
|
282
|
+
|
283
|
+
it "should redirect without voting" do
|
284
|
+
@<%= object_name %>.stub!(:has_already_voted? => true)
|
285
|
+
@<%= object_name %>.votes.should_not_receive(:build).with(:user => @user, :vote => "first").and_return(@vote)
|
286
|
+
|
287
|
+
do_post
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
describe "when a new voter" do
|
292
|
+
before do
|
293
|
+
@<%= object_name %>.stub!(:has_already_voted? => false)
|
294
|
+
end
|
295
|
+
|
296
|
+
describe "with successful save" do
|
297
|
+
def do_post
|
298
|
+
@vote.should_receive(:save).and_return(true)
|
299
|
+
post :vote, :id => 1, :<%= object_name %> => {"vote" => "first"}
|
300
|
+
end
|
301
|
+
|
302
|
+
it "should create a new vote" do
|
303
|
+
@<%= object_name %>.votes.should_receive(:build).with(:user => @user, :vote => "first").and_return(@vote)
|
304
|
+
do_post
|
305
|
+
end
|
306
|
+
|
307
|
+
it "should set a flash message" do
|
308
|
+
do_post
|
309
|
+
flash[:notice].should == "Vote cast!"
|
310
|
+
end
|
311
|
+
|
312
|
+
it "should redirect to the <%= object_name %>" do
|
313
|
+
do_post
|
314
|
+
response.should redirect_to(<%= object_name %>s_path)
|
315
|
+
end
|
316
|
+
|
317
|
+
end
|
318
|
+
|
319
|
+
describe "with failed save" do
|
320
|
+
|
321
|
+
def do_post
|
322
|
+
@vote.should_receive(:save).and_return(false)
|
323
|
+
post :vote, :id => 1, :<%= object_name %> => {}
|
324
|
+
end
|
325
|
+
|
326
|
+
it "should show an error message" do
|
327
|
+
do_post
|
328
|
+
flash[:error].should == "Something happened..."
|
329
|
+
end
|
330
|
+
|
331
|
+
it "should redirec to the <%= object_name %>" do
|
332
|
+
do_post
|
333
|
+
response.should redirect_to(<%= object_name %>s_path)
|
334
|
+
end
|
335
|
+
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
end
|
341
|
+
|
342
|
+
# unless @<%= object_name %>.has_already_voted?(current_user)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe <%= class_name %>sHelper do
|
4
|
+
|
5
|
+
describe " -- add_option_link" do
|
6
|
+
it "should provide a link that inserts a new option" do
|
7
|
+
pending("This is passing, but needs RJS love")
|
8
|
+
<%= object_name %> = mock_model(<%= class_name %>)
|
9
|
+
|
10
|
+
page = mock(page, :insert_html => self)
|
11
|
+
helper.should_receive(:link_to_function).with("some_name").and_return(page)
|
12
|
+
|
13
|
+
helper.add_option_link(<%= object_name %>, "some_name")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe <%= class_name %>sController do
|
4
|
+
describe "route generation" do
|
5
|
+
it "should map #index" do
|
6
|
+
route_for(:controller => "<%= object_name %>s", :action => "index").should == "/<%= object_name %>s"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should map #new" do
|
10
|
+
route_for(:controller => "<%= object_name %>s", :action => "new").should == "/<%= object_name %>s/new"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should map #edit" do
|
14
|
+
route_for(:controller => "<%= object_name %>s", :action => "edit", :id => 1).should == "/<%= object_name %>s/1/edit"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should map #update" do
|
18
|
+
route_for(:controller => "<%= object_name %>s", :action => "update", :id => 1).should == "/<%= object_name %>s/1"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should map #destroy" do
|
22
|
+
route_for(:controller => "<%= object_name %>s", :action => "destroy", :id => 1).should == "/<%= object_name %>s/1"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "route recognition" do
|
27
|
+
it "should generate params for #index" do
|
28
|
+
params_from(:get, "/<%= object_name %>s").should == {:controller => "<%= object_name %>s", :action => "index"}
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should generate params for #new" do
|
32
|
+
params_from(:get, "/<%= object_name %>s/new").should == {:controller => "<%= object_name %>s", :action => "new"}
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should generate params for #create" do
|
36
|
+
params_from(:post, "/<%= object_name %>s").should == {:controller => "<%= object_name %>s", :action => "create"}
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should generate params for #edit" do
|
40
|
+
params_from(:get, "/<%= object_name %>s/1/edit").should == {:controller => "<%= object_name %>s", :action => "edit", :id => "1"}
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should generate params for #update" do
|
44
|
+
params_from(:put, "/<%= object_name %>s/1").should == {:controller => "<%= object_name %>s", :action => "update", :id => "1"}
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should generate params for #destroy" do
|
48
|
+
params_from(:delete, "/<%= object_name %>s/1").should == {:controller => "<%= object_name %>s", :action => "destroy", :id => "1"}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<div>
|
2
|
+
<b>
|
3
|
+
<center>
|
4
|
+
Results after <%%= pluralize(<%= object_name %>.total_votes.to_i, 'vote') %>
|
5
|
+
</center>
|
6
|
+
</b>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div>
|
10
|
+
<b>Candidates:</b>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<ol>
|
14
|
+
<%% <%= object_name %>.options.each do |option| %>
|
15
|
+
<li><%%= option %></li>
|
16
|
+
<%% end %>
|
17
|
+
</ol>
|
18
|
+
|
19
|
+
<center>
|
20
|
+
<%%= Gchart.pie_3d(:size=>'350x150', :bar_colors=>'2F87ED', :legend=><%= object_name %>.pie_legend, :data=><%= object_name %>.current_results_percentages, :format=>'image_tag') %>
|
21
|
+
</center>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%% if <%= object_name %>.ends_in_tie? %>
|
2
|
+
<center>
|
3
|
+
We have a tie between
|
4
|
+
<b>
|
5
|
+
<%%= <%= object_name %>.winners.to_sentence %>!
|
6
|
+
</b>
|
7
|
+
</center>
|
8
|
+
|
9
|
+
<%% else %>
|
10
|
+
<center>
|
11
|
+
...and the winner is:
|
12
|
+
<b>
|
13
|
+
<%%= <%= object_name %>.winner %>!
|
14
|
+
</b>
|
15
|
+
</center>
|
16
|
+
<%% end %>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<div style="width: 500px; margin: auto; margin-bottom: 20px;" id="<%%= dom_id(<%= object_name %>) %>">
|
2
|
+
<%%= <%= object_name %>.name %>
|
3
|
+
Ends on <%%= <%= object_name %>.ends_at %>
|
4
|
+
|
5
|
+
<hr/>
|
6
|
+
|
7
|
+
<p>
|
8
|
+
<%%= <%= object_name %>.description %>
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<hr/>
|
12
|
+
|
13
|
+
<%% if <%= object_name %>.can_by_voted_on_by(current_user) %>
|
14
|
+
<div id="cast_vote_div">
|
15
|
+
<%%= render :partial => "vote", :locals => {:<%= object_name %> => <%= object_name %>} %>
|
16
|
+
</div>
|
17
|
+
<%% end %>
|
18
|
+
|
19
|
+
<%% if <%= object_name %>.has_already_voted?(current_user) %>
|
20
|
+
<div id="current_results_div">
|
21
|
+
<%%= render :partial => "current_results", :locals => {:<%= object_name %> => <%= object_name %>} %>
|
22
|
+
</div>
|
23
|
+
<%% end %>
|
24
|
+
|
25
|
+
<%% unless <%= object_name %>.active? %>
|
26
|
+
<div id="winner_div">
|
27
|
+
<%%= render :partial => "final_results", :locals => {:<%= object_name %> => <%= object_name %>} %>
|
28
|
+
</div>
|
29
|
+
<%% end %>
|
30
|
+
|
31
|
+
|
32
|
+
<%%= link_to "Edit", edit_<%= object_name %>_path(<%= object_name %>) %>
|
33
|
+
<%%= link_to "Delete", <%= object_name %>_path(<%= object_name %>), :method => :delete, :confirm => "Are you sure?" %>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<h1>Edit <%= object_name %></h1>
|
2
|
+
|
3
|
+
<%% form_for(@<%= object_name %>) do |f| %>
|
4
|
+
<%%= f.hidden_field :created_by_id, :value => current_user.id %>
|
5
|
+
|
6
|
+
<p>
|
7
|
+
<%%= f.label :name %>
|
8
|
+
<%%= f.text_field :name %>
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<p>
|
12
|
+
<%%= f.label :ends_at %>
|
13
|
+
<%%= f.text_field :ends_at %>
|
14
|
+
</p>
|
15
|
+
|
16
|
+
<p>
|
17
|
+
<%%= f.label :description %>
|
18
|
+
<%%= f.text_area :description %>
|
19
|
+
</p>
|
20
|
+
|
21
|
+
<p>
|
22
|
+
<%%= f.label :options %>
|
23
|
+
<div id="options"></div>
|
24
|
+
<%% @<%= object_name %>.options.each do |option| %>
|
25
|
+
<%%= render :partial => 'option_form', :locals => {:option => option} %>
|
26
|
+
<%% end %>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<br />
|
30
|
+
<%%= add_option_link(@<%= object_name %>, "Add an option") %>
|
31
|
+
</p>
|
32
|
+
|
33
|
+
<p>
|
34
|
+
<%%= f.submit "Save" %>
|
35
|
+
-or-
|
36
|
+
<%%= link_to "Cancel", <%= object_name %>s_path %>
|
37
|
+
</p>
|
38
|
+
<%% end %>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<h1>New <%= object_name %></h1>
|
2
|
+
|
3
|
+
<%% form_for(@<%= object_name %>) do |f| %>
|
4
|
+
<%%= f.hidden_field :created_by_id, :value => current_user.id %>
|
5
|
+
|
6
|
+
<p>
|
7
|
+
<%%= f.label :name %>
|
8
|
+
<%%= f.text_field :name %>
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<p>
|
12
|
+
<%%= f.label :ends_at %>
|
13
|
+
<%%= f.text_field :ends_at %>
|
14
|
+
</p>
|
15
|
+
|
16
|
+
<p>
|
17
|
+
<%%= f.label :description %>
|
18
|
+
<%%= f.text_area :description %>
|
19
|
+
</p>
|
20
|
+
|
21
|
+
<p>
|
22
|
+
<%%= f.label :options %>
|
23
|
+
<div id="options"></div>
|
24
|
+
<%% 2.times do %>
|
25
|
+
<%%= render :partial => 'option_form', :locals => {:option => []} %>
|
26
|
+
<%% end %>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<br />
|
30
|
+
<%%= add_option_link(@<%= object_name %>, "Add an option") %>
|
31
|
+
</p>
|
32
|
+
|
33
|
+
<p>
|
34
|
+
<%%= f.submit "Create" %>
|
35
|
+
-or-
|
36
|
+
<%%= link_to "Cancel", <%= object_name %>s_path %>
|
37
|
+
</p>
|
38
|
+
<%% end %>
|
data/init.rb
ADDED
File without changes
|
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mdarby-pollster
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Darby
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-11 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A Rails gem that generates an entire MVC stack for user polling on your Rails 2x app
|
17
|
+
email: matt@matt-darby.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- MIT-LICENSE
|
26
|
+
- README.textile
|
27
|
+
- Rakefile
|
28
|
+
- init.rb
|
29
|
+
- install.rb
|
30
|
+
- generators/pollster/pollster_generator.rb
|
31
|
+
- generators/pollster/templates/create_pollster_tables.rb
|
32
|
+
- generators/pollster/templates/poll.rb
|
33
|
+
- generators/pollster/templates/poll_vote.rb
|
34
|
+
- generators/pollster/templates/polls_controller.rb
|
35
|
+
- generators/pollster/templates/polls_helper.rb
|
36
|
+
- generators/pollster/templates/spec/poll_spec.rb
|
37
|
+
- generators/pollster/templates/spec/poll_vote_spec.rb
|
38
|
+
- generators/pollster/templates/spec/polls_controller_spec.rb
|
39
|
+
- generators/pollster/templates/spec/polls_helper_spec.rb
|
40
|
+
- generators/pollster/templates/spec/polls_routing_spec.rb
|
41
|
+
- generators/pollster/templates/views/_current_results.html.erb
|
42
|
+
- generators/pollster/templates/views/_final_results.html.erb
|
43
|
+
- generators/pollster/templates/views/_option_form.html.erb
|
44
|
+
- generators/pollster/templates/views/_poll.html.erb
|
45
|
+
- generators/pollster/templates/views/_vote.html.erb
|
46
|
+
- generators/pollster/templates/views/edit.html.erb
|
47
|
+
- generators/pollster/templates/views/index.html.erb
|
48
|
+
- generators/pollster/templates/views/new.html.erb
|
49
|
+
- generators/pollster/USAGE
|
50
|
+
- uninstall.rb
|
51
|
+
has_rdoc: false
|
52
|
+
homepage: http://github.com/mdarby/pollster
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
version:
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
requirements: []
|
71
|
+
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.2.0
|
74
|
+
signing_key:
|
75
|
+
specification_version: 2
|
76
|
+
summary: Easy user polling for your Rails app
|
77
|
+
test_files: []
|
78
|
+
|