Skip to content

Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬

1.0 KB
Raw Blame
require 'rails_helper'

RSpec.describe Devise::Mailer do
  it 'carries the pending Shopify install redirect in the confirmation link' do
    user = create(:user, skip_confirmation: false)
    redirect_url = "settings/integrations/shopify?shopify_pending_install=#{'a' * 32}"
    mail = described_class
           .with(redirect_url: redirect_url)
           .confirmation_instructions(user, 'confirmation-token')

    expect(CGI.unescapeHTML(mail.body.to_s)).to include(
      "route_url=settings%2Fintegrations%2Fshopify%3Fshopify_pending_install%3D#{'a' * 32}"
    )
  end

  it 'carries the requested redirect in the password edit link' do
    user = create(:user)
    redirect_url = 'settings/billing?plan_handle=growth'
    mail = described_class
           .with(redirect_url: redirect_url, sso_account_id: '42')
           .reset_password_instructions(user, 'reset-token')

    expect(CGI.unescapeHTML(mail.body.to_s)).to include(
      'route_url=settings%2Fbilling%3Fplan_handle%3Dgrowth',
      'sso_account_id=42'
    )
  end
end