From 403490364a710744021c1e7c542c070586454be8 Mon Sep 17 00:00:00 2001 From: zhitomirskiyi Date: Fri, 21 Jan 2011 10:50:53 -0800 Subject: [PATCH] fixed datapoint_spec. fixed labels on graph --- app/models/statistic.rb | 6 +++++- spec/models/data_point_spec.rb | 14 ++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/models/statistic.rb b/app/models/statistic.rb index 8d55182df..c5da05dc5 100644 --- a/app/models/statistic.rb +++ b/app/models/statistic.rb @@ -45,7 +45,11 @@ class Statistic < ActiveRecord::Base g.data("Users", self.distribution_as_array) h = {} - distribution.keys.each{|k| h[k.to_i] = k.to_s } + distribution.keys.each do |k| + if k.to_i%10 ==0 + h[k.to_i] = k.to_s + end + end g.labels = h g.to_blob diff --git a/spec/models/data_point_spec.rb b/spec/models/data_point_spec.rb index 71ab389cb..476316638 100644 --- a/spec/models/data_point_spec.rb +++ b/spec/models/data_point_spec.rb @@ -6,18 +6,24 @@ describe DataPoint do @time = Time.now end - context '.posts_per_day_last_week' do + describe '.users_with_posts_on_day' do before do 1.times do |n| - alice.post(:status_message, :message => 'hi', :to => alice.aspects.first) + p = alice.post(:status_message, :message => 'hi', :to => alice.aspects.first) + p.created_at = @time + p.save end 5.times do |n| - bob.post(:status_message, :message => 'hi', :to => bob.aspects.first) + p = bob.post(:status_message, :message => 'hi', :to => bob.aspects.first) + p.created_at = @time + p.save end 10.times do |n| - eve.post(:status_message, :message => 'hi', :to => eve.aspects.first) + p = eve.post(:status_message, :message => 'hi', :to => eve.aspects.first) + p.created_at = @time + p.save end end