-
-
Notifications
You must be signed in to change notification settings - Fork 1k
uninitialized constant ActionMailer::DeliveryJob with latest rails/master #2531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
If I define the missing const unless ActionMailer.const_defined?("DeliveryJob")
ActionMailer.const_set(:DeliveryJob, ActionMailer::MailDeliveryJob)
end I get other errors: 4) Pitches::AcceptPitch#call when buyer has not connected with stripe updates pitch status
Failure/Error:
expect { call }.to change { pitch.reload.state }.to("buyer_accepted")
.and have_enqueued_email(PitchMailer, :request_accepted)
NameError:
uninitialized constant ActionMailer::Parameterized::DeliveryJob
Did you mean? ActionMailer::DeliveryJob So it does seem like something has changed and rspec-rails needs to be tweaked. |
What if you replace in
- job[:job] <= ActionMailer::DeliveryJob
+ defined?(ActionMailer::DeliveryJob) && job[:job] <= ActionMailer::DeliveryJob will it fix your error? |
@pirj then I get the other error I posted: Failures:
1) Article sends emails about published articles
Failure/Error:
expect { Article.create!(title: "Some title", slug: "some-title") }
.to have_enqueued_email(ArticleMailer, :article_published)
NameError:
uninitialized constant ActionMailer::Parameterized::DeliveryJob
Did you mean? ActionMailer::MailDeliveryJob
# ./spec/models/article_spec.rb:7:in `block (2 levels) in <main>' |
This seems to be the commit! rails/rails@ddc7fb6 |
If I change: # FROM
def parameterized_mail?(job)
RSpec::Rails::FeatureCheck.has_action_mailer_parameterized? && job[:job] <= ActionMailer::Parameterized::DeliveryJob
end
# TO
def parameterized_mail?(job)
RSpec::Rails::FeatureCheck.has_action_mailer_parameterized? && job[:job] <= ActionMailer::MailDeliveryJob
end At least the error goes away. |
Added this in # This patches rspec-rails to support rails 7.0
module RSpec
module Rails
module Matchers
class HaveEnqueuedMail
def legacy_mail?(job)
defined?(ActionMailer::DeliveryJob) && job[:job] <= ActionMailer::DeliveryJob
end
def parameterized_mail?(job)
RSpec::Rails::FeatureCheck.has_action_mailer_parameterized? && job[:job] <= ActionMailer::MailDeliveryJob
end
def unified_mail?(job)
RSpec::Rails::FeatureCheck.has_action_mailer_unified_delivery? && job[:job] <= ActionMailer::MailDeliveryJob
end
end
end
end
end |
Would you open a PR with a proper fix that would work with 5.2, 6.0, 6.1 and most recent 7.0? |
You won't even have to write new specs for this code. Rails edge build already fails:
|
Perfect, I'll sort out a PR then! Thanks for following up |
fixes #2531 Co-authored-by: Mikael Henriksson <[email protected]>
1. ActionMailer::DeliveryJob does not exist anymore 2. ActionMailer::Parameterized::DeliveryJob According to my research they have both been superseeded by ActionMailer::MailDeliveryJob Closes rspec#2531
Added PR @pirj, please let me know if there is anything I should improve to get it merged. |
1. ActionMailer::DeliveryJob does not exist anymore 2. ActionMailer::Parameterized::DeliveryJob According to my research they have both been superseeded by ActionMailer::MailDeliveryJob Closes rspec#2531
1. ActionMailer::DeliveryJob does not exist anymore 2. ActionMailer::Parameterized::DeliveryJob According to my research they have both been superseeded by ActionMailer::MailDeliveryJob Closes rspec#2531
1. ActionMailer::DeliveryJob does not exist anymore 2. ActionMailer::Parameterized::DeliveryJob According to my research they have both been superseeded by ActionMailer::MailDeliveryJob Closes #2531
1. ActionMailer::DeliveryJob does not exist anymore 2. ActionMailer::Parameterized::DeliveryJob According to my research they have both been superseeded by ActionMailer::MailDeliveryJob Closes #2531
Any chance of getting this in a tagged release soon? |
I'm still getting the same error with edit: Sweet, I see someone else gave this a 👍 , I felt like maybe I had done something incredibly wrong, and everyone else was good to go :D |
@Petercopter The fix is in |
The problem with |
Other RSpec libs do not depend on
Yes, as this is a Rails 7 specific fix, and the version to support Rails 7 is RSpec Rails 6. |
This has been released as Rails 7 support is only via version 6.x per our versioning strategy. |
To prevent possible issues with ActiveMailer: rspec/rspec-rails#2531
To prevent possible issues with ActiveMailer: rspec/rspec-rails#2531
What Ruby, Rails and RSpec versions are you using?
Ruby version: 3.0.2
Rails version: 7.0.0 @ a0e14a8bfebf5f4bd4b66d1d468c844ab3e9d704
RSpec version: 5.0.2
Observed behaviour
Expected behaviour
Test was working before upgrading rails version
Can you provide an example app?
https://github.com/mhenrixon/rspec-rails-issue-2531 shows the error nicely
The text was updated successfully, but these errors were encountered: