Commit 71acdfab3f33135367bc93118b9bd27e29be0a95
1 parent
81256140
Exists in
master
and in
1 other branch
fix export tests to use their own question var
question variable used in export tests was colliding with other question variable
Showing
1 changed file
with
16 additions
and
16 deletions
Show diff stats
spec/models/question_spec.rb
@@ -298,19 +298,19 @@ describe Question do | @@ -298,19 +298,19 @@ describe Question do | ||
298 | 298 | ||
299 | context "exporting data" do | 299 | context "exporting data" do |
300 | before(:all) do | 300 | before(:all) do |
301 | - @question = Factory.create(:aoi_question) | ||
302 | - user = @question.site | 301 | + @aoi_question = Factory.create(:aoi_question) |
302 | + user = @aoi_question.site | ||
303 | 303 | ||
304 | - @question.it_should_autoactivate_ideas = true | ||
305 | - @question.save! | 304 | + @aoi_question.it_should_autoactivate_ideas = true |
305 | + @aoi_question.save! | ||
306 | 306 | ||
307 | visitor = user.visitors.find_or_create_by_identifier('visitor identifier') | 307 | visitor = user.visitors.find_or_create_by_identifier('visitor identifier') |
308 | 100.times.each do |num| | 308 | 100.times.each do |num| |
309 | - user.create_choice(visitor.identifier, @question, {:data => num.to_s, :local_identifier => "example creator"}) | 309 | + user.create_choice(visitor.identifier, @aoi_question, {:data => num.to_s, :local_identifier => "example creator"}) |
310 | end | 310 | end |
311 | 311 | ||
312 | 200.times.each do |num| | 312 | 200.times.each do |num| |
313 | - @p = @question.picked_prompt | 313 | + @p = @aoi_question.picked_prompt |
314 | 314 | ||
315 | @a = user.record_appearance(visitor, @p) | 315 | @a = user.record_appearance(visitor, @p) |
316 | 316 | ||
@@ -340,10 +340,10 @@ describe Question do | @@ -340,10 +340,10 @@ describe Question do | ||
340 | 340 | ||
341 | 341 | ||
342 | it "should export vote data to a csv file" do | 342 | it "should export vote data to a csv file" do |
343 | - filename = @question.export('votes') | 343 | + filename = @aoi_question.export('votes') |
344 | 344 | ||
345 | filename.should_not be nil | 345 | filename.should_not be nil |
346 | - filename.should match /.*ideamarketplace_#{@question.id}_votes[.]csv$/ | 346 | + filename.should match /.*ideamarketplace_#{@aoi_question.id}_votes[.]csv$/ |
347 | File.exists?(filename).should be_true | 347 | File.exists?(filename).should be_true |
348 | # Not specifying exact file syntax, it's likely to change frequently | 348 | # Not specifying exact file syntax, it's likely to change frequently |
349 | # | 349 | # |
@@ -357,10 +357,10 @@ describe Question do | @@ -357,10 +357,10 @@ describe Question do | ||
357 | it "should notify redis after completing an export, if redis option set" do | 357 | it "should notify redis after completing an export, if redis option set" do |
358 | redis_key = "test_key123" | 358 | redis_key = "test_key123" |
359 | $redis.del(redis_key) # clear if key exists already | 359 | $redis.del(redis_key) # clear if key exists already |
360 | - filename = @question.export('votes', :response_type => 'redis', :redis_key => redis_key) | 360 | + filename = @aoi_question.export('votes', :response_type => 'redis', :redis_key => redis_key) |
361 | 361 | ||
362 | filename.should_not be nil | 362 | filename.should_not be nil |
363 | - filename.should match /.*ideamarketplace_#{@question.id}_votes[.]csv$/ | 363 | + filename.should match /.*ideamarketplace_#{@aoi_question.id}_votes[.]csv$/ |
364 | File.exists?(filename).should be_true | 364 | File.exists?(filename).should be_true |
365 | $redis.lpop(redis_key).should == filename | 365 | $redis.lpop(redis_key).should == filename |
366 | $redis.del(redis_key) # clean up | 366 | $redis.del(redis_key) # clean up |
@@ -372,10 +372,10 @@ describe Question do | @@ -372,10 +372,10 @@ describe Question do | ||
372 | end | 372 | end |
373 | 373 | ||
374 | it "should export non vote data to a csv file" do | 374 | it "should export non vote data to a csv file" do |
375 | - filename = @question.export('non_votes') | 375 | + filename = @aoi_question.export('non_votes') |
376 | 376 | ||
377 | filename.should_not be nil | 377 | filename.should_not be nil |
378 | - filename.should match /.*ideamarketplace_#{@question.id}_non_votes[.]csv$/ | 378 | + filename.should match /.*ideamarketplace_#{@aoi_question.id}_non_votes[.]csv$/ |
379 | File.exists?(filename).should be_true | 379 | File.exists?(filename).should be_true |
380 | 380 | ||
381 | # Not specifying exact file syntax, it's likely to change frequently | 381 | # Not specifying exact file syntax, it's likely to change frequently |
@@ -390,10 +390,10 @@ describe Question do | @@ -390,10 +390,10 @@ describe Question do | ||
390 | end | 390 | end |
391 | 391 | ||
392 | it "should export idea data to a csv file" do | 392 | it "should export idea data to a csv file" do |
393 | - filename = @question.export('ideas') | 393 | + filename = @aoi_question.export('ideas') |
394 | 394 | ||
395 | filename.should_not be nil | 395 | filename.should_not be nil |
396 | - filename.should match /.*ideamarketplace_#{@question.id}_ideas[.]csv$/ | 396 | + filename.should match /.*ideamarketplace_#{@aoi_question.id}_ideas[.]csv$/ |
397 | File.exists?(filename).should be_true | 397 | File.exists?(filename).should be_true |
398 | # Not specifying exact file syntax, it's likely to change frequently | 398 | # Not specifying exact file syntax, it's likely to change frequently |
399 | # | 399 | # |
@@ -405,12 +405,12 @@ describe Question do | @@ -405,12 +405,12 @@ describe Question do | ||
405 | end | 405 | end |
406 | 406 | ||
407 | it "should raise an error when given an unsupported export type" do | 407 | it "should raise an error when given an unsupported export type" do |
408 | - lambda { @question.export("blahblahblah") }.should raise_error | 408 | + lambda { @aoi_question.export("blahblahblah") }.should raise_error |
409 | end | 409 | end |
410 | 410 | ||
411 | it "should export data and schedule a job to delete export after X days" do | 411 | it "should export data and schedule a job to delete export after X days" do |
412 | Delayed::Job.delete_all | 412 | Delayed::Job.delete_all |
413 | - filename = @question.export_and_delete('votes', :delete_at => 2.days.from_now) | 413 | + filename = @aoi_question.export_and_delete('votes', :delete_at => 2.days.from_now) |
414 | 414 | ||
415 | Delayed::Job.count.should == 1 | 415 | Delayed::Job.count.should == 1 |
416 | Delayed::Job.delete_all | 416 | Delayed::Job.delete_all |