Sha256: 12c5ac750f583ff770cce807673e83b9dfdf1d4f770cb05300874c18a38b570f

Contents?: true

Size: 2 KB

Versions: 5

Compression:

Stored size: 2 KB

Contents

module Clearance
  module Test
    module Unit
      module ClearanceMailerTest

        def self.included(mailer_test)
          mailer_test.class_eval do

            context "A change password email" do
              setup do
                @user  = Factory(:user)
                @email = ClearanceMailer.create_change_password @user
              end

              should "set its from address to DO_NOT_REPLY" do
                assert_equal DO_NOT_REPLY, @email.from[0]
              end

              should "contain a link to edit the user's password" do
                host = ActionMailer::Base.default_url_options[:host]
                regexp = %r{http://#{host}/users/#{@user.id}/password/edit\?token=#{@user.token}}
                assert_match regexp, @email.body
              end

              should "be sent to the user" do
                assert_equal [@user.email], @email.to
              end

              should "set its subject" do
                assert_match /Change your password/, @email.subject
              end
            end

            context "A confirmation email" do
              setup do
                @user  = Factory(:user)
                @email = ClearanceMailer.create_confirmation @user
              end

              should "set its recipient to the given user" do
                assert_equal @user.email, @email.to[0]
              end

              should "set its subject" do
                assert_match /Account confirmation/, @email.subject
              end

              should "set its from address to DO_NOT_REPLY" do
                assert_equal DO_NOT_REPLY, @email.from[0]
              end

              should "contain a link to confirm the user's account" do
                host = ActionMailer::Base.default_url_options[:host]
                regexp = %r{http://#{host}/users/#{@user.id}/confirmation/new\?token=#{@user.token}}
                assert_match regexp, @email.body
              end
            end

          end
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
jeffrafter-clearance-0.5.4 lib/clearance/test/unit/clearance_mailer_test.rb
kellyfelkins-clearance-0.5.6 lib/clearance/test/unit/clearance_mailer_test.rb
thoughtbot-clearance-0.5.3 lib/clearance/test/unit/clearance_mailer_test.rb
thoughtbot-clearance-0.5.4 lib/clearance/test/unit/clearance_mailer_test.rb
thoughtbot-clearance-0.5.6 lib/clearance/test/unit/clearance_mailer_test.rb