Sha256: 42a4e9a1e8139629b23ec673e429f873ae6112ee69214c613f1f91b89c98cd46

Contents?: true

Size: 1.06 KB

Versions: 12

Compression:

Stored size: 1.06 KB

Contents

require "test_helper"

class UseVanityMailerTest < ActionMailer::TestCase
  tests VanityMailer

  def setup
    super
    metric :sugar_high
    new_ab_test :pie_or_cake do
      metrics :sugar_high
      alternatives :pie, :cake
      default :pie
    end
  end

  def test_js_enabled_still_adds_participant
    Vanity.playground.use_js!
    experiment(:pie_or_cake).identify { }
    experiment(:pie_or_cake).chooses(:pie)
    VanityMailer.ab_test_subject(nil)


    alts = experiment(:pie_or_cake).alternatives
    assert_equal 1, alts.map(&:participants).sum
  end

  def test_returns_different_alternatives
    experiment(:pie_or_cake).identify { }

    experiment(:pie_or_cake).chooses(:pie)
    email = VanityMailer.ab_test_subject(nil)
    assert_equal 'pie', email.subject

    experiment(:pie_or_cake).chooses(:cake)
    email = VanityMailer.ab_test_subject(nil)
    assert_equal 'cake', email.subject
  end

  def test_tracking_image_is_rendered
    email = VanityMailer.ab_test_content(nil)
    assert email.body =~ /<img/
    assert email.body =~ /_identity=/
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
vanity-2.2.10 test/frameworks/rails/action_mailer_test.rb
vanity-2.2.9 test/frameworks/rails/action_mailer_test.rb
vanity-2.2.8 test/frameworks/rails/action_mailer_test.rb
vanity-2.2.7 test/frameworks/rails/action_mailer_test.rb
vanity-2.2.6 test/frameworks/rails/action_mailer_test.rb
vanity-2.2.4 test/frameworks/rails/action_mailer_test.rb
vanity-2.2.3 test/frameworks/rails/action_mailer_test.rb
vanity-2.2.2 test/frameworks/rails/action_mailer_test.rb
vanity-2.2.1 test/frameworks/rails/action_mailer_test.rb
vanity-2.2.0 test/frameworks/rails/action_mailer_test.rb
vanity-2.1.2 test/frameworks/rails/action_mailer_test.rb
vanity-2.1.1 test/frameworks/rails/action_mailer_test.rb