forked from tobi/delayed_job
-
Notifications
You must be signed in to change notification settings - Fork 956
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1121 from johnnyshields/patch-3
Make .delay method work with ActionMailer::Parameterized::Mailer
- Loading branch information
Showing
3 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,29 @@ def signup(email) | |
end | ||
end | ||
end | ||
|
||
if defined?(ActionMailer::Parameterized::Mailer) | ||
describe ActionMailer::Parameterized::Mailer do | ||
describe 'delay' do | ||
it 'enqueues a PerformableEmail job' do | ||
expect do | ||
job = MyMailer.with(:foo => 1, :bar => 2).delay.signup('[email protected]') | ||
expect(job.payload_object.class).to eq(Delayed::PerformableMailer) | ||
expect(job.payload_object.object.class).to eq(ActionMailer::Parameterized::Mailer) | ||
expect(job.payload_object.object.instance_variable_get('@mailer')).to eq(MyMailer) | ||
expect(job.payload_object.object.instance_variable_get('@params')).to eq(:foo => 1, :bar => 2) | ||
expect(job.payload_object.method_name).to eq(:signup) | ||
expect(job.payload_object.args).to eq(['[email protected]']) | ||
end.to change { Delayed::Job.count }.by(1) | ||
end | ||
end | ||
|
||
describe 'delay on a mail object' do | ||
it 'raises an exception' do | ||
expect do | ||
MyMailer.with(:foo => 1, :bar => 2).signup('[email protected]').delay | ||
end.to raise_error(RuntimeError) | ||
end | ||
end | ||
end | ||
end |