2013-07-06 19:20:35 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe WidgetsController do
|
|
|
|
|
|
|
|
before(:each) do
|
|
|
|
@widget = Widget.find(1)
|
|
|
|
Widget.stub(:find).and_return(@widget)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should log impression at the per action level" do
|
|
|
|
get "show", :id=> 1
|
|
|
|
Impression.all.size.should eq 12
|
|
|
|
get "index"
|
|
|
|
Impression.all.size.should eq 13
|
|
|
|
get "new"
|
|
|
|
Impression.all.size.should eq 13
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should not log impression when user-agent is in wildcard list" do
|
2013-07-11 05:02:26 +00:00
|
|
|
request.stub(:user_agent).and_return('somebot')
|
2013-07-06 19:20:35 +00:00
|
|
|
get "show", :id=> 1
|
|
|
|
Impression.all.size.should eq 11
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should not log impression when user-agent is in the bot list" do
|
2013-07-11 05:02:26 +00:00
|
|
|
request.stub(:user_agent).and_return('Acoon Robot v1.50.001')
|
2013-07-06 19:20:35 +00:00
|
|
|
get "show", :id=> 1
|
|
|
|
Impression.all.size.should eq 11
|
|
|
|
end
|
|
|
|
|
|
|
|
context "impressionist unique options" do
|
|
|
|
|
|
|
|
it "should log unique impressions at the per action level" do
|
|
|
|
get "show", :id=> 1
|
|
|
|
Impression.all.size.should eq 12
|
|
|
|
get "show", :id=> 2
|
|
|
|
Impression.all.size.should eq 13
|
|
|
|
get "show", :id => 2
|
|
|
|
Impression.all.size.should eq 13
|
|
|
|
get "index"
|
|
|
|
Impression.all.size.should eq 14
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should log unique impressions only once per id" do
|
|
|
|
get "show", :id=> 1
|
|
|
|
Impression.all.size.should eq 12
|
|
|
|
|
|
|
|
get "show", :id=> 2
|
|
|
|
Impression.all.size.should eq 13
|
|
|
|
|
|
|
|
get "show", :id => 2
|
|
|
|
Impression.all.size.should eq 13
|
|
|
|
|
|
|
|
get "index"
|
|
|
|
Impression.all.size.should eq 14
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|