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,7 +256,7 @@ describe Question do | ||
256 | end | 256 | end |
257 | 257 | ||
258 | it "should properly calculate with no responses" do | 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 | end | 260 | end |
261 | 261 | ||
262 | it "should properly calculate with 2 sessions" do | 262 | it "should properly calculate with 2 sessions" do |
@@ -291,8 +291,8 @@ describe Question do | @@ -291,8 +291,8 @@ describe Question do | ||
291 | @q = Factory.create(:aoi_question) | 291 | @q = Factory.create(:aoi_question) |
292 | end | 292 | end |
293 | it "should be calculated properly with no uploaded choices" do | 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 | end | 296 | end |
297 | 297 | ||
298 | it "should be calculated properly with some choices and votes" do | 298 | it "should be calculated properly with some choices and votes" do |
@@ -305,21 +305,21 @@ describe Question do | @@ -305,21 +305,21 @@ describe Question do | ||
305 | end | 305 | end |
306 | end | 306 | end |
307 | 307 | ||
308 | - context "ratio of uploaded ideas to participation" do | 308 | + context "rate of uploaded ideas to participation" do |
309 | before(:all) do | 309 | before(:all) do |
310 | truncate_all | 310 | truncate_all |
311 | @q = Factory.create(:aoi_question) | 311 | @q = Factory.create(:aoi_question) |
312 | end | 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 | @q.sessions_with_uploaded_ideas.should == 0 | 314 | @q.sessions_with_uploaded_ideas.should == 0 |
315 | @q.sessions_with_participation.should == 0 | 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 | # 10 voting only sessions | 318 | # 10 voting only sessions |
319 | 10.times { Factory.create(:vote_new_user, :question => @q) } | 319 | 10.times { Factory.create(:vote_new_user, :question => @q) } |
320 | @q.sessions_with_uploaded_ideas.should == 0 | 320 | @q.sessions_with_uploaded_ideas.should == 0 |
321 | @q.sessions_with_participation.should == 10 | 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 | # 7 users who voted and added ideas | 324 | # 7 users who voted and added ideas |
325 | 7.times do | 325 | 7.times do |
@@ -328,13 +328,13 @@ describe Question do | @@ -328,13 +328,13 @@ describe Question do | ||
328 | end | 328 | end |
329 | @q.sessions_with_uploaded_ideas.should == 7 | 329 | @q.sessions_with_uploaded_ideas.should == 7 |
330 | @q.sessions_with_participation.should == 17 | 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 | # 2 users who only skip | 333 | # 2 users who only skip |
334 | 2.times { Factory.create(:skip_new_user, :question => @q) } | 334 | 2.times { Factory.create(:skip_new_user, :question => @q) } |
335 | @q.sessions_with_uploaded_ideas.should == 7 | 335 | @q.sessions_with_uploaded_ideas.should == 7 |
336 | @q.sessions_with_participation.should == 19 | 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 | # 3 users who did everything | 339 | # 3 users who did everything |
340 | 3.times do | 340 | 3.times do |
@@ -344,13 +344,13 @@ describe Question do | @@ -344,13 +344,13 @@ describe Question do | ||
344 | end | 344 | end |
345 | @q.sessions_with_uploaded_ideas.should == 10 | 345 | @q.sessions_with_uploaded_ideas.should == 10 |
346 | @q.sessions_with_participation.should == 22 | 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 | # 5 users who only added ideas | 349 | # 5 users who only added ideas |
350 | 5.times { Factory.create(:choice_new_user, :question => @q) } | 350 | 5.times { Factory.create(:choice_new_user, :question => @q) } |
351 | @q.sessions_with_uploaded_ideas.should == 15 | 351 | @q.sessions_with_uploaded_ideas.should == 15 |
352 | @q.sessions_with_participation.should == 27 | 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 | end | 355 | end |
356 | end | 356 | end |
@@ -364,7 +364,7 @@ describe Question do | @@ -364,7 +364,7 @@ describe Question do | ||
364 | it "should give proper stats required for vote rate" do | 364 | it "should give proper stats required for vote rate" do |
365 | @q.total_uniq_sessions.should == 0 | 365 | @q.total_uniq_sessions.should == 0 |
366 | @q.sessions_with_vote.should == 0 | 366 | @q.sessions_with_vote.should == 0 |
367 | - @q.vote_rate.should == 0.0 | 367 | + @q.vote_rate.should == nil |
368 | 368 | ||
369 | # add new session + appearance, but no vote | 369 | # add new session + appearance, but no vote |
370 | Factory.create(:appearance_new_user, :question => @q) | 370 | Factory.create(:appearance_new_user, :question => @q) |