We provide our Clients a way to preview mass emails being delivered to their Users. For some of the emails, we mock (OpenStruct
) some objects and use them in the email view:
UserMailer:class UserMailer < ApplicationMailer
def about_to_expire_card_reminder ... if params[:email_preview] @subject += " (email de prueba)" @user_default_credit_card = mock_credit_card end send_email(subject: @subject) end def mock_credit_card OpenStruct.new(last_four_digits: "1234 (tarjeta de prueba)", expiration_date: 10.days.from_now.to_date) endend
We were forcing errors today and noticed that the OpenStruct
that mock_credit_card
returns does not show up in the Sidekiq
admin page where the retrying Job shows.
Retrying Job info:
Next Retry: in 3 minutesRetry Count: 4Queue: mailersJob: ActionMailer::MailDeliveryJobArguments: "UserMailer", "about_to_expire_card_reminder", "deliver_now", {"params"=>{"user"=>{"_aj_globalid"=>"gid://database/User/1"}, "to"=>info@testemail.com", "email_preview"=>true, "aj_symbol_keys"=>["user,"to","email_preview"]}, "args"=>[],"_aj_symbol_keys"=>["params","args"]}Error: ActionView::Template:Error: undefined method "last_four_digits" for #struct expiration_date="2021-03-31">
Where does Sidekiq
store the mocked OpenStruct
object? Is it serialized? Does it take up memory until the job is finished or dropped?
Any insights would be appreciated. Let me know if you need more code.