aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/action_mailroom/test_helper.rb13
-rw-r--r--lib/tasks/action_mailroom.rake17
-rw-r--r--test/test_helper.rb11
3 files changed, 18 insertions, 23 deletions
diff --git a/lib/action_mailroom/test_helper.rb b/lib/action_mailroom/test_helper.rb
new file mode 100644
index 0000000000..af9e3ad559
--- /dev/null
+++ b/lib/action_mailroom/test_helper.rb
@@ -0,0 +1,13 @@
+module ActionMailroom
+ module TestHelper
+ # Create an InboundEmail record using an eml fixture in the format of message/rfc822
+ # referenced with +fixture_name+ located in +test/fixtures/files/fixture_name+.
+ def create_inbound_email(fixture_name)
+ ActionMailroom::InboundEmail.create!.tap do |inbound_email|
+ inbound_email.raw_email.attach \
+ ActiveStorage::Blob.create_after_upload! \
+ io: file_fixture(fixture_name).open, filename: fixture_name, content_type: 'message/rfc822'
+ end
+ end
+ end
+end
diff --git a/lib/tasks/action_mailroom.rake b/lib/tasks/action_mailroom.rake
index ce80fcf55e..2cf692cc0f 100644
--- a/lib/tasks/action_mailroom.rake
+++ b/lib/tasks/action_mailroom.rake
@@ -4,8 +4,8 @@ namespace :action_mailroom do
# Prevent migration installation task from showing up twice.
Rake::Task["install:migrations"].clear_comments
- desc "Copy over the migration and fixtures"
- task install: %w( environment active_storage:install copy_migration copy_fixtures )
+ desc "Copy over the migration"
+ task install: %w( environment active_storage:install copy_migration )
task :copy_migration do
if Rake::Task.task_defined?("action_mailroom:install:migrations")
@@ -14,17 +14,4 @@ namespace :action_mailroom do
Rake::Task["app:action_mailroom:install:migrations"].invoke
end
end
-
- FIXTURE_TEMPLATE_PATH = File.expand_path("../templates/fixtures.yml", __dir__)
- FIXTURE_APP_DIR_PATH = Rails.root.join("test/fixtures/action_mailroom")
- FIXTURE_APP_PATH = FIXTURE_APP_DIR_PATH.join("inbound_emails.yml")
-
- task :copy_fixtures do
- if File.exist?(FIXTURE_APP_PATH)
- puts "Won't copy Action Mailbox fixtures as it already exists"
- else
- FileUtils.mkdir FIXTURE_APP_DIR_PATH
- FileUtils.cp FIXTURE_TEMPLATE_PATH, FIXTURE_APP_PATH
- end
- end
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 9344a57fd7..c05cc87896 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -20,13 +20,8 @@ if ActiveSupport::TestCase.respond_to?(:fixture_path=)
ActiveSupport::TestCase.fixtures :all
end
+require "action_mailroom/test_helper"
+
class ActiveSupport::TestCase
- private
- def create_inbound_email(fixture_name)
- ActionMailroom::InboundEmail.create!.tap do |inbound_email|
- inbound_email.raw_email.attach \
- ActiveStorage::Blob.create_after_upload! \
- io: file_fixture(fixture_name).open, filename: fixture_name, content_type: 'message/rfc822'
- end
- end
+ include ActionMailroom::TestHelper
end