Additional email_job_spec cleanup
This commit is contained in:
parent
bef544bf63
commit
bfa3e2db3b
5 changed files with 0 additions and 65 deletions
|
@ -1,8 +0,0 @@
|
||||||
Description:
|
|
||||||
Create a new EmailJob subclass in lib/job_types
|
|
||||||
|
|
||||||
Example:
|
|
||||||
rails generate email_job JobName arg1 arg2
|
|
||||||
|
|
||||||
This will create:
|
|
||||||
A file called lib/job_types/job_name_job.rb with a module named JobNameJob
|
|
|
@ -1,11 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class EmailJobGenerator < Rails::Generators::NamedBase
|
|
||||||
argument :attribs, type: :array
|
|
||||||
source_root File.expand_path('templates', __dir__)
|
|
||||||
def copy_file_to_lib
|
|
||||||
template 'email_job_template.erb', "lib/job_types/#{name.underscore}.rb"
|
|
||||||
template 'email_job_spec_template.erb', "spec/lib/job_types/#{name.underscore}_spec.rb"
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,13 +0,0 @@
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
require 'rails_helper.rb'
|
|
||||||
|
|
||||||
describe JobTypes::<%= name %> do
|
|
||||||
describe '.perform' do
|
|
||||||
it 'calls the correct active mailer' do
|
|
||||||
expect(fail).to receive(:fail).with(fail).and_wrap_original{|m, *args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer}
|
|
||||||
|
|
||||||
job = JobTypes::<%= name %>.new(fail)
|
|
||||||
job.perform
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,14 +0,0 @@
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
module JobTypes
|
|
||||||
class <%= name %> < EmailJob
|
|
||||||
attr_reader <%= attribs.map{|i| ":#{i}"}.join(", ") %>
|
|
||||||
|
|
||||||
def initialize(<%= attribs.join(", ") %>)<% attribs.each {|i| %>
|
|
||||||
@<%= i %> = <%= i %><% }%>
|
|
||||||
end
|
|
||||||
|
|
||||||
def perform
|
|
||||||
fail
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,19 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
require 'rails_helper.rb'
|
|
||||||
|
|
||||||
describe JobTypes::EmailJob do
|
|
||||||
describe '.reschedule_at' do
|
|
||||||
it '50 attempts takes about 24 hours' do
|
|
||||||
job = JobTypes::EmailJob.new
|
|
||||||
initial_time = Time.utc(2020, 5, 5)
|
|
||||||
end_time = initial_time + 1.day
|
|
||||||
current_time = initial_time
|
|
||||||
50.times.map { |i| i + 1 }.each do |i|
|
|
||||||
current_time = job.reschedule_at(current_time, i)
|
|
||||||
end
|
|
||||||
expect(current_time).to be_between(end_time - 5.minutes, end_time + 5.minutes)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue