Ensure source file autoload call only triggered on create

This commit is contained in:
2018-05-07 14:54:48 -03:00
parent 6fb5f04e90
commit 58f9c95f4e
3 changed files with 12 additions and 1 deletions
+3
View File
@@ -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"