From 33c7400919b69befffae7e551e03b5d37cb66974 Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Mon, 21 Feb 2011 20:06:54 -0800 Subject: [PATCH] clean up fixture builder --- spec/support/fixture_builder.rb | 20 +++----------------- spec/support/user_methods.rb | 6 ++++++ 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/spec/support/fixture_builder.rb b/spec/support/fixture_builder.rb index 85440e887..e86fef8f1 100644 --- a/spec/support/fixture_builder.rb +++ b/spec/support/fixture_builder.rb @@ -23,23 +23,9 @@ FixtureBuilder.configure do |fbuilder| stat = Statistic.new time = Time.now - 1.times do - p = frodo.post(:status_message, :message => 'hi', :to => frodo.aspects.first) - p.created_at = time - p.save! - end - - 5.times do - p = sam.post(:status_message, :message => 'hi', :to => sam.aspects.first) - p.created_at = time - p.save! - end - - 10.times do - p = bilbo.post(:status_message, :message => 'hi', :to => bilbo.aspects.first) - p.created_at = time - p.save! - end + 1.times { frodo.post_at_time(time) } + 5.times { sam.post_at_time(time) } + 10.times { bilbo.post_at_time(time) } (0..10).each do |n| stat.data_points << DataPoint.users_with_posts_on_day(time, n) diff --git a/spec/support/user_methods.rb b/spec/support/user_methods.rb index b5facc06d..e47c2fd68 100644 --- a/spec/support/user_methods.rb +++ b/spec/support/user_methods.rb @@ -40,4 +40,10 @@ class User c end end + + def post_at_time(time) + p = self.post(:status_message, :message => 'hi', :to => self.aspects.first) + p.created_at = time + p.save! + end end