Sha256: 239baddaf0e00b2c81750a6b77dc340fcd7708ce0aa5d29a25754b3980f0293a

Contents?: true

Size: 1.71 KB

Versions: 3

Compression:

Stored size: 1.71 KB

Contents

require File.dirname(__FILE__) + '/test_helper.rb'
include Rubaidh::GoogleAnalyticsViewHelper
include ActionView::Helpers::UrlHelper
include ActionView::Helpers::TagHelper

class ViewHelpersTest < Test::Unit::TestCase
  def test_link_to_tracked_should_return_a_tracked_link
    assert_equal "<a href=\"http://www.example.com\" onclick=\"javascript:pageTracker._trackPageview('/sites/linked');\">Link</a>", link_to_tracked('Link', '/sites/linked', "http://www.example.com" )
  end
  
  def test_link_to_tracked_with_legacy_should_return_a_tracked_link
    Rubaidh::GoogleAnalytics.legacy_mode = true
    assert_equal "<a href=\"http://www.example.com\" onclick=\"javascript:urchinTracker('/sites/linked');\">Link</a>", link_to_tracked('Link', '/sites/linked', "http://www.example.com" )
  end
  
  def test_link_to_tracked_if_with_true_should_return_a_tracked_link
    assert_equal "<a href=\"http://www.example.com\" onclick=\"javascript:pageTracker._trackPageview('/sites/linked');\">Link</a>", link_to_tracked_if(true, 'Link', '/sites/linked', "http://www.example.com" )
  end
  
  def test_link_to_tracked_if_with_false_should_return_unlinked_text
    assert_equal "Link", link_to_tracked_if(false, 'Link', '/sites/linked', "http://www.example.com" )
  end
  
  def test_link_to_tracked_unless_with_false_should_return_a_tracked_link
    assert_equal "<a href=\"http://www.example.com\" onclick=\"javascript:pageTracker._trackPageview('/sites/linked');\">Link</a>", link_to_tracked_unless(false, 'Link', '/sites/linked', "http://www.example.com" )
  end
  
  def test_link_to_tracked_unless_with_true_should_return_unlinked_text
    assert_equal "Link", link_to_tracked_unless(true, 'Link', '/sites/linked', "http://www.example.com" )
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
markcatley-google_analytics-1.0.20080714 test/view_helpers_test.rb
markcatley-google_analytics-1.0.20080715 test/view_helpers_test.rb
markcatley-google_analytics-1.0.20080717 test/view_helpers_test.rb