Sha256: 8ca8ecb62a82bae2f654f3cba126a895581015440b52d7d8a905f881b4807230
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
require 'test_helper' class ViewTest < ActionView::TestCase test 'include' do self.request = ActionDispatch::TestRequest.new with_env 'production' do tag = google_analytics_include_tag('id') assert_includes tag, 'ga("create", "id", "auto");' assert_includes tag, 'ga("send", "pageview", {});' assert_includes tag, 'http://www.google-analytics.com/analytics.js' tag = google_analytics_include_tag('id', other: 'value') assert_includes tag, 'ga("create", "id", "auto");' assert_includes tag, 'ga("send", "pageview", {"other":"value"});' assert_includes tag, 'http://www.google-analytics.com/analytics.js' end with_env 'development' do assert_not google_analytics_include_tag end end test 'event' do with_env 'production' do assert_includes( google_analytics_event_tag('Popup', 'click'), 'ga("send", "event", "Popup", "click", {});' ) assert_includes( google_analytics_event_tag('Video', 'play', 'ad.mp4', 10, non_interactive: 'value'), 'ga("send", "event", "Video", "play", "ad.mp4", 10, {"nonInteractive":"value"});' ) end with_env 'development' do assert_not google_analytics_event_tag end end private def with_env(value) old_env = Rails.env Rails.env = value yield Rails.env = old_env end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
analytics-rails-4.0.0.1 | test/view_test.rb |
analytics-rails-4.0.0.0 | test/view_test.rb |