Commit 6e6f1ed8181ff3a9c1cccb1f08f73b8d764a2026
1 parent
27a15109
Exists in
master
and in
1 other branch
fix up tests to expect nil values instead of 0.0
Showing
1 changed file
with
12 additions
and
12 deletions
Show diff stats
spec/models/question_spec.rb
... | ... | @@ -256,7 +256,7 @@ describe Question do |
256 | 256 | end |
257 | 257 | |
258 | 258 | it "should properly calculate with no responses" do |
259 | - @q.median_responses_per_session.should == 0 | |
259 | + @q.median_responses_per_session.should == nil | |
260 | 260 | end |
261 | 261 | |
262 | 262 | it "should properly calculate with 2 sessions" do |
... | ... | @@ -291,8 +291,8 @@ describe Question do |
291 | 291 | @q = Factory.create(:aoi_question) |
292 | 292 | end |
293 | 293 | it "should be calculated properly with no uploaded choices" do |
294 | - @q.votes_per_uploaded_choice.should == 0.0 | |
295 | - @q.votes_per_uploaded_choice(true).should == 0.0 | |
294 | + @q.votes_per_uploaded_choice.should == nil | |
295 | + @q.votes_per_uploaded_choice(true).should == nil | |
296 | 296 | end |
297 | 297 | |
298 | 298 | it "should be calculated properly with some choices and votes" do |
... | ... | @@ -305,21 +305,21 @@ describe Question do |
305 | 305 | end |
306 | 306 | end |
307 | 307 | |
308 | - context "ratio of uploaded ideas to participation" do | |
308 | + context "rate of uploaded ideas to participation" do | |
309 | 309 | before(:all) do |
310 | 310 | truncate_all |
311 | 311 | @q = Factory.create(:aoi_question) |
312 | 312 | end |
313 | - it "should give proper stats required for idea:participation ratio" do | |
313 | + it "should give proper stats required for idea:participation rate" do | |
314 | 314 | @q.sessions_with_uploaded_ideas.should == 0 |
315 | 315 | @q.sessions_with_participation.should == 0 |
316 | - @q.upload_to_participation_ratio.should == 0.0 | |
316 | + @q.upload_to_participation_rate.should == nil | |
317 | 317 | |
318 | 318 | # 10 voting only sessions |
319 | 319 | 10.times { Factory.create(:vote_new_user, :question => @q) } |
320 | 320 | @q.sessions_with_uploaded_ideas.should == 0 |
321 | 321 | @q.sessions_with_participation.should == 10 |
322 | - @q.upload_to_participation_ratio.should == 0.0 | |
322 | + @q.upload_to_participation_rate.should == 0.0 | |
323 | 323 | |
324 | 324 | # 7 users who voted and added ideas |
325 | 325 | 7.times do |
... | ... | @@ -328,13 +328,13 @@ describe Question do |
328 | 328 | end |
329 | 329 | @q.sessions_with_uploaded_ideas.should == 7 |
330 | 330 | @q.sessions_with_participation.should == 17 |
331 | - @q.upload_to_participation_ratio.round(3).should == 0.412 | |
331 | + @q.upload_to_participation_rate.round(3).should == 0.412 | |
332 | 332 | |
333 | 333 | # 2 users who only skip |
334 | 334 | 2.times { Factory.create(:skip_new_user, :question => @q) } |
335 | 335 | @q.sessions_with_uploaded_ideas.should == 7 |
336 | 336 | @q.sessions_with_participation.should == 19 |
337 | - @q.upload_to_participation_ratio.round(3).should == 0.368 | |
337 | + @q.upload_to_participation_rate.round(3).should == 0.368 | |
338 | 338 | |
339 | 339 | # 3 users who did everything |
340 | 340 | 3.times do |
... | ... | @@ -344,13 +344,13 @@ describe Question do |
344 | 344 | end |
345 | 345 | @q.sessions_with_uploaded_ideas.should == 10 |
346 | 346 | @q.sessions_with_participation.should == 22 |
347 | - @q.upload_to_participation_ratio.round(3).should == 0.455 | |
347 | + @q.upload_to_participation_rate.round(3).should == 0.455 | |
348 | 348 | |
349 | 349 | # 5 users who only added ideas |
350 | 350 | 5.times { Factory.create(:choice_new_user, :question => @q) } |
351 | 351 | @q.sessions_with_uploaded_ideas.should == 15 |
352 | 352 | @q.sessions_with_participation.should == 27 |
353 | - @q.upload_to_participation_ratio.round(3).should == 0.556 | |
353 | + @q.upload_to_participation_rate.round(3).should == 0.556 | |
354 | 354 | |
355 | 355 | end |
356 | 356 | end |
... | ... | @@ -364,7 +364,7 @@ describe Question do |
364 | 364 | it "should give proper stats required for vote rate" do |
365 | 365 | @q.total_uniq_sessions.should == 0 |
366 | 366 | @q.sessions_with_vote.should == 0 |
367 | - @q.vote_rate.should == 0.0 | |
367 | + @q.vote_rate.should == nil | |
368 | 368 | |
369 | 369 | # add new session + appearance, but no vote |
370 | 370 | Factory.create(:appearance_new_user, :question => @q) | ... | ... |