diff --git a/lib/statistics.rb b/lib/statistics.rb index 4ccccc533..5b4da1165 100644 --- a/lib/statistics.rb +++ b/lib/statistics.rb @@ -72,6 +72,17 @@ SQL SQL end + def fb_connected_distribution_sql + < "Services::Facebook", :user => bob) + bob.save! + + eve.services << Factory(:service, :type => "Services::Facebook", :user => eve) + eve.save! + + + @result = [{"id" => alice.id , "count" => 0, "connected" => 0 }, + {"id" => bob.id , "count" => 1, "connected" => 1 }, + {"id" => eve.id , "count" => 0, "connected" => 1 }, + {"id" => local_luke.id , "count" => 0, "connected" => 0 }, + {"id" => local_leia.id , "count" => 0, "connected" => 0 }] + + User.connection.select_all(@stats.fb_connected_distribution_sql).should =~ @result + end + end + ["posts_count", "comments_count", "invites_sent_count", "tags_followed_count", "mentions_count", "sign_in_count", "contacts_sharing_with_count" ].each do |method| @@ -101,6 +121,7 @@ describe Statistics do end end + describe "#correlation" do it 'returns the correlation coefficient' do @stats.correlation([1,2],[1,2]).to_s.should == 1.0.to_s