# frozen_string_literal: true

require "spec_helper"

module Decidim
  describe BlockUserMailer do
    let(:user) { create(:user, :confirmed, organization:, newsletter_notifications_at: nil, newsletter_token: token) }
    let(:token) { SecureRandom.base58(24) }
    let(:organization) { create(:organization) }
    let(:organization_url) { "http://www.example.com" }
    let(:decidim) { Decidim::Core::Engine.routes.url_helpers }

    describe "notify" do
      let(:mail) { described_class.notify(user, token) }

      it "parses the subject" do
        expect(mail.subject).to eq("Your account was blocked by #{translated_attribute(organization.name)}")
      end

      it "parses the body" do
        expect(email_body(mail)).to include("Your account was blocked.")
        expect(email_body(mail)).to include("Reason: ")
      end

      it "includes no-reply message" do
        expect(email_body(mail)).to include("This email was sent from a notification email address that cannot accept incoming email. Please do not reply to this message.")
      end
    end
  end
end
