From bfa3e2db3b168b9a32372c2bf02884803f3324d1 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Fri, 8 Nov 2019 16:19:34 -0600 Subject: [PATCH] Additional email_job_spec cleanup --- lib/generators/email_job/USAGE | 8 -------- .../email_job/email_job_generator.rb | 11 ----------- .../templates/email_job_spec_template.erb | 13 ------------- .../templates/email_job_template.erb | 14 -------------- spec/lib/job_types/email_job_spec.rb | 19 ------------------- 5 files changed, 65 deletions(-) delete mode 100644 lib/generators/email_job/USAGE delete mode 100644 lib/generators/email_job/email_job_generator.rb delete mode 100644 lib/generators/email_job/templates/email_job_spec_template.erb delete mode 100644 lib/generators/email_job/templates/email_job_template.erb delete mode 100644 spec/lib/job_types/email_job_spec.rb diff --git a/lib/generators/email_job/USAGE b/lib/generators/email_job/USAGE deleted file mode 100644 index dd722287..00000000 --- a/lib/generators/email_job/USAGE +++ /dev/null @@ -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 diff --git a/lib/generators/email_job/email_job_generator.rb b/lib/generators/email_job/email_job_generator.rb deleted file mode 100644 index 67138a48..00000000 --- a/lib/generators/email_job/email_job_generator.rb +++ /dev/null @@ -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 diff --git a/lib/generators/email_job/templates/email_job_spec_template.erb b/lib/generators/email_job/templates/email_job_spec_template.erb deleted file mode 100644 index c5993d68..00000000 --- a/lib/generators/email_job/templates/email_job_spec_template.erb +++ /dev/null @@ -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 \ No newline at end of file diff --git a/lib/generators/email_job/templates/email_job_template.erb b/lib/generators/email_job/templates/email_job_template.erb deleted file mode 100644 index 5969657c..00000000 --- a/lib/generators/email_job/templates/email_job_template.erb +++ /dev/null @@ -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 \ No newline at end of file diff --git a/spec/lib/job_types/email_job_spec.rb b/spec/lib/job_types/email_job_spec.rb deleted file mode 100644 index a831c16a..00000000 --- a/spec/lib/job_types/email_job_spec.rb +++ /dev/null @@ -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