Sha256: 31fa480d6d0d44b654da81816aaa6b4eed7b948342f9e3facdd9810cbb17d6b8

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

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
    request.stub!(:user_agent).and_return('somebot')
    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
    request.stub!(:user_agent).and_return('Acoon Robot v1.50.001')
    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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
impressionist-1.4.1 test_app/spec/controllers/widgets_controller_spec.rb