Sha256: 6430c377a02e1686223a53af7c864a01a99388e9971a22c08b3924542543e9ad

Contents?: true

Size: 1.1 KB

Versions: 9

Compression:

Stored size: 1.1 KB

Contents

require 'test_helper'

class GoogleAnalyticsControllerTest < ActionController::TestCase
  tests Garails::GoogleAnalyticsController

  context "GET to :utm" do
    setup do
      flexmock(@controller, :rand => 405451725)
      stub_analytics("0xd5d59357458cc280")
      get :utm, :format => :gif
    end
    should respond_with :success
    should assign_to(:visitor_id)
  end

  context "GET to :utm with guid" do
    setup do
      stub_analytics("0x80620d96c658ed0f")
      request.env["HTTP_X_DCMGUID"] = "blah"
      get :utm, :format => :gif
    end
    should respond_with :success
    should assign_to(:visitor_id)
  end

  def stub_analytics(vid)
    query = {
      :utmac => "MO-12345678-9", :utmcc => "__utma=999.999.999.999.999.1;", :utmcs => "UTF-8", 
      :utmhn => "example.org", :utmip => "0.0.0.0", :utmr => "-", :utmul => "en-us", 
      :utmvid => vid, :utmwv => "4.4sh" }
    stub_request(:get, "http://www.google-analytics.com/__utm.gif").
      with(:query => query, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Rails%20Testing'}).
      to_return(:status => 200, :body => "", :headers => {})
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
garails-0.3.0 test/controllers/google_analytics_controller_test.rb
garails-0.2.0 test/controllers/google_analytics_controller_test.rb
garails-0.1.4 test/controllers/google_analytics_controller_test.rb
garails-0.1.3 test/controllers/google_analytics_controller_test.rb
garails-0.1.2 test/controllers/google_analytics_controller_test.rb
garails-0.1.1 test/controllers/google_analytics_controller_test.rb
garails-0.1.0 test/controllers/google_analytics_controller_test.rb
garails-0.0.7 test/controllers/google_analytics_controller_test.rb
garails-0.0.6 test/controllers/google_analytics_controller_test.rb