Skip to content

Commit

Permalink
Fix SubmissionFileUpdateJob not being enqueued
Browse files Browse the repository at this point in the history
CLoses #100
  • Loading branch information
Earlopain committed Oct 7, 2023
1 parent 5fa59fc commit 889bc7a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class Application < Rails::Application
},
}

# TODO: Remove this
config.active_record.run_after_transaction_callbacks_in_order_defined = false

config.action_controller.action_on_unpermitted_parameters = :raise

config.cache_store = :file_store, Rails.root.join("tmp/file_store")
Expand Down
12 changes: 12 additions & 0 deletions test/model/submission_file_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require "test_helper"

class SubmissionFileTest < ActiveSupport::TestCase
include ActiveJob::TestHelper

describe "#original" do
it "must be attached on create" do
e = assert_raises(ActiveRecord::RecordInvalid) { create(:submission_file, skip_original_validation: false) }
Expand All @@ -21,5 +23,15 @@ class SubmissionFileTest < ActiveSupport::TestCase
assert_not sm.original.attached?
assert_predicate(sm, :valid?)
end

it "enqueues the update job on create" do
create(:submission_file_with_original, file_name: "1.webp")
assert_enqueued_jobs 1, only: SubmissionFileUpdateJob
end

it "enqueues nothing if the attachment didn't change" do
sm = create(:submission_file_with_original, file_name: "1.webp")
assert_no_enqueued_jobs { sm.save }
end
end
end

0 comments on commit 889bc7a

Please sign in to comment.