Skip to content

Commit

Permalink
fix: add spec
Browse files Browse the repository at this point in the history
  • Loading branch information
afthabvp committed Apr 8, 2024
1 parent 3c53d0d commit 2a36504
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions server/spec/lib/reverse_etl/extractors/incremental_delta_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,20 @@
let(:model) { create(:model) }

context "when the primary key is blank" do
it "does not create or update sync record" do
message = double("Message", record: double("Record", data: { "id" => nil }))
expect { subject.send(:process_record, message, sync_run, model) }.not_to(change { SyncRecord.count })
it "does not call update_or_create_sync_record" do
message = double("Message", record: double("Record", data: { "TestPrimaryKey" => nil }))
expect(subject).not_to receive(:find_or_initialize_sync_record)
expect(subject).not_to receive(:update_or_create_sync_record)
subject.send(:process_record, message, sync_run, model)
end
end

context "when the primary key is not blank" do
it "calls find_or_initialize_sync_record and update_or_create_sync_record" do
message = double("Message", record: double("Record", data: { "TestPrimaryKey" => 1 }))
expect(subject).to receive(:find_or_initialize_sync_record)
expect(subject).to receive(:update_or_create_sync_record)
subject.send(:process_record, message, sync_run, model)
end
end
end
Expand Down

0 comments on commit 2a36504

Please sign in to comment.