Ensure source file autoload call only triggered on create
This commit is contained in:
@@ -34,7 +34,7 @@ module Dunlop::SourceFileModel
|
||||
event(:failed) { transition any => :failed }
|
||||
end
|
||||
|
||||
after_commit { autoload! }
|
||||
after_commit(on: :create) { autoload! }
|
||||
|
||||
self::Job = Class.new "#{name.deconstantize}::ApplicationJob".constantize do
|
||||
def perform(source_file_id)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
class ApplicationJob < ActiveJob::Base
|
||||
|
||||
end
|
||||
@@ -4,6 +4,14 @@ describe SourceFile::MySource do
|
||||
subject { create('source_file/my_source', original_file: fixture_file("source_files/my_source_1.csv") ) }
|
||||
let(:model) { SourceRecord::MySource }
|
||||
|
||||
describe '#autoload!' do
|
||||
it 'calls on create, not on update' do
|
||||
expect_any_instance_of(described_class).to receive(:autoload!).once
|
||||
subject # create
|
||||
subject.update(state: 'loading')
|
||||
subject.update(state: 'pending')
|
||||
end
|
||||
end
|
||||
describe "#first_line" do
|
||||
it "returns the first line" do
|
||||
subject.first_line(subject.original_file.path).should eq "my_date,my_var,My count,my_num,my_truth"
|
||||
|
||||
Reference in New Issue
Block a user