2011-02-04 04:13:41 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Impression do
|
2011-02-13 19:18:34 +00:00
|
|
|
fixtures :articles,:impressions,:posts
|
2011-02-04 04:13:41 +00:00
|
|
|
|
|
|
|
before(:each) do
|
|
|
|
@article = Article.find(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should save a blank impression for an Article that has 10 impressions" do
|
|
|
|
@article.impressions.create
|
|
|
|
@article.impressions.size.should eq 11
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should save an impression with a message" do
|
2011-02-13 19:18:34 +00:00
|
|
|
@article.impressions.create(:message=>"test message")
|
2011-02-04 04:13:41 +00:00
|
|
|
@article.impressions.last.message.should eq "test message"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should return the view count with no date range specified" do
|
|
|
|
@article.impression_count.should eq 10
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should return unique view count with no date range specified" do
|
|
|
|
@article.unique_impression_count.should eq 7
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should return view count with only start date specified" do
|
|
|
|
@article.impression_count("2011-01-01").should eq 8
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should return view count with whole date range specified" do
|
|
|
|
@article.impression_count("2011-01-01","2011-01-02").should eq 7
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should return unique view count with only start date specified" do
|
|
|
|
@article.unique_impression_count("2011-01-01").should eq 7
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should return unique view count with date range specified" do
|
|
|
|
@article.unique_impression_count("2011-01-01","2011-01-02").should eq 7
|
|
|
|
end
|
|
|
|
end
|