update with changes from Production branch

This commit is contained in:
Lee Lawlor
2014-02-17 12:05:39 -05:00
parent 5b640cf9d8
commit a4937fb2e5
384 changed files with 14690 additions and 2242 deletions

View File

@ -1,15 +1,106 @@
require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the FeedHelper. For example:
#
# describe FeedHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe FeedHelper do
pending "add some examples to (or delete) #{__FILE__}"
describe "feed_select_data" do
before :each do
@channel = FactoryGirl.create(:channel)
end
it "extracts selection criteria from the request parameters with no time params" do
#params = {:average => 10}
helper.stub(:params).and_return(params)
only = Feed.select_options(@channel, params)
only.should include(:created_at, :entry_id)
end
it "extracts selection criteria from the request parameters " do
params = {:average => 10}
helper.stub(:params).and_return(params)
only = Feed.select_options(@channel, params)
only.should include(:created_at)
end
end
describe "feeds_into_averages" do
before :each do
userAttr = FactoryGirl.attributes_for(:user)
@user = User.create!(userAttr)
@channel = FactoryGirl.create(:channel, :user => @user)
now = Time.utc(2013,1,1)
feed1 = FactoryGirl.create(:feed, :channel => @channel, :created_at => now)
feed2 = FactoryGirl.create(:feed, :channel => @channel, :created_at => now - 5.minutes)
feed3 = FactoryGirl.create(:feed, :channel => @channel, :created_at => now - 8.minutes)
end
it "averages feed values based on a timeslice" do
feeds = Feed.find(:all, :order => :created_at)
params = {:average => 10}
helper.stub(:params).and_return(params)
timeslices = helper.feeds_into_averages(feeds, params)
timeslices.size.should eq(2)
end
end
describe "feeds_into_median" do
before :each do
userAttr = FactoryGirl.attributes_for(:user)
@user = User.create!(userAttr)
@channel = FactoryGirl.create(:channel, :user => @user)
now = Time.utc(2013,1,1)
feed1 = FactoryGirl.create(:feed, :channel => @channel, :created_at => now)
feed2 = FactoryGirl.create(:feed, :channel => @channel, :created_at => now - 5.minutes)
feed3 = FactoryGirl.create(:feed, :channel => @channel, :created_at => now - 8.minutes)
end
it "median feed values based on a timeslice" do
feeds = Feed.find(:all, :order => :created_at)
params = {:median => 10}
helper.stub(:params).and_return(params)
timeslices = helper.feeds_into_medians(feeds, params)
timeslices.size.should eq(2)
end
end
describe "feeds_into_sums" do
before :each do
userAttr = FactoryGirl.attributes_for(:user)
@user = User.create!(userAttr)
@channel = FactoryGirl.create(:channel, :user => @user)
now = Time.utc(2013,1,1)
feed1 = FactoryGirl.create(:feed, :channel => @channel, :created_at => now)
feed2 = FactoryGirl.create(:feed, :channel => @channel, :created_at => now - 5.minutes)
feed3 = FactoryGirl.create(:feed, :channel => @channel, :created_at => now - 8.minutes)
end
it "sum feed values based on a timeslice" do
feeds = Feed.find(:all, :order => :created_at)
params = {:sum => 10}
helper.stub(:params).and_return(params)
timeslices = helper.feeds_into_sums(feeds, params)
timeslices.size.should eq(2)
end
end
describe "feeds_into_timescales" do
before :each do
userAttr = FactoryGirl.attributes_for(:user)
@user = User.create!(userAttr)
@channel = FactoryGirl.create(:channel, :user => @user)
now = Time.utc(2013,1,1)
feed1 = FactoryGirl.create(:feed, :channel => @channel, :created_at => now)
feed2 = FactoryGirl.create(:feed, :channel => @channel, :created_at => now - 5.minutes)
feed3 = FactoryGirl.create(:feed, :channel => @channel, :created_at => now - 8.minutes)
end
it "timescale feed values based on a timeslice" do
feeds = Feed.find(:all, :order => :created_at)
params = {:timescale => 10}
helper.stub(:params).and_return(params)
timeslices = helper.feeds_into_timescales(feeds, params)
timeslices.size.should eq(2)
end
end
end