Sha256: d94bb0fefe3c7b126aabffdae6740bdb77799bd04e80ef854acc55c74c76a432

Contents?: true

Size: 1.43 KB

Versions: 22

Compression:

Stored size: 1.43 KB

Contents

require "spec_helper"

describe ClearanceMailer do
  it "is from DO_NOT_REPLY" do
    user = create(:user)
    user.forgot_password!

    email = ClearanceMailer.change_password(user)

    expect(Clearance.configuration.mailer_sender).to eq(email.from[0])
  end

  it "is sent to user" do
    user = create(:user)
    user.forgot_password!

    email = ClearanceMailer.change_password(user)

    expect(email.to.first).to eq(user.email)
  end

  it "sets its subject" do
    user = create(:user)
    user.forgot_password!

    email = ClearanceMailer.change_password(user)

    expect(email.subject).to include("Change your password")
  end

  it "has html and plain text parts" do
    user = create(:user)
    user.forgot_password!

    email = ClearanceMailer.change_password(user)

    expect(email.body.parts.length).to eq 2
    expect(email.text_part).to be_present
    expect(email.html_part).to be_present
  end

  it "contains a link to edit the password" do
    user = create(:user)
    user.forgot_password!
    host = ActionMailer::Base.default_url_options[:host]
    link = "http://#{host}/users/#{user.id}/password/edit" \
      "?token=#{user.confirmation_token}"

    email = ClearanceMailer.change_password(user)

    expect(email.text_part.body).to include(link)
    expect(email.html_part.body).to include(link)
    expect(email.html_part.body).to have_css(
      "a",
      text: I18n.t("clearance_mailer.change_password.link_text")
    )
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
clearance-2.3.0 spec/mailers/clearance_mailer_spec.rb
clearance-2.2.1 spec/mailers/clearance_mailer_spec.rb
clearance-2.2.0 spec/mailers/clearance_mailer_spec.rb
clearance-2.1.0 spec/mailers/clearance_mailer_spec.rb
clearance-2.0.0 spec/mailers/clearance_mailer_spec.rb
clearance-2.0.0.beta2 spec/mailers/clearance_mailer_spec.rb
clearance-2.0.0.beta1 spec/mailers/clearance_mailer_spec.rb
clearance-1.17.0 spec/mailers/clearance_mailer_spec.rb
clearance-1.16.2 spec/mailers/clearance_mailer_spec.rb
clearance-1.16.1 spec/mailers/clearance_mailer_spec.rb
clearance-1.16.0 spec/mailers/clearance_mailer_spec.rb
clearance-1.15.1 spec/mailers/clearance_mailer_spec.rb
clearance-1.15.0 spec/mailers/clearance_mailer_spec.rb
clearance-1.14.2 spec/mailers/clearance_mailer_spec.rb
clearance-1.14.1 spec/mailers/clearance_mailer_spec.rb
clearance-1.14.0 spec/mailers/clearance_mailer_spec.rb
clearance-1.13.0 spec/mailers/clearance_mailer_spec.rb
clearance-1.12.1 spec/mailers/clearance_mailer_spec.rb
clearance-1.12.0 spec/mailers/clearance_mailer_spec.rb
clearance-1.11.0 spec/mailers/clearance_mailer_spec.rb