Skip to content

Commit

Permalink
Adds tests for the StagingInterceptor to boost coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
danschmidt5189 committed Jan 27, 2025
1 parent c8bae01 commit c472f84
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/mailers/staging_interceptor_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'rails_helper'

RSpec.describe Interceptors::StagingInterceptor, type: :mailer do
around do |test|
ActionMailer::Base.register_interceptor(Interceptors::StagingInterceptor)
test.run
ActionMailer::Base.unregister_interceptor(Interceptors::StagingInterceptor)
end

it 'rewrites outbound mail to the test list' do
mail = NotificationsMailer.#
mail.cc %w[a@berkeley.edu b@berkeley.edu]
mail.bcc %w[c@berkeley.edu d@berkeley.edu]
mail.deliver_now

expect(mail.to).to eq %w[lib-testmail@lists.berkeley.edu]
expect(mail.cc).to be_empty
expect(mail.bcc).to be_empty
expect(mail.header[:x_lap_service].value).to eq 'geodata'
expect(mail.header[:x_original_to].value).to eq 'fake@berkeley.edu'
expect(mail.header[:x_original_cc].value).to eq 'a@berkeley.edu, b@berkeley.edu'
expect(mail.header[:x_original_bcc].value).to eq 'c@berkeley.edu, d@berkeley.edu'
end
end

0 comments on commit c472f84

Please # to comment.