Skip to content

Commit

Permalink
Use should_skip_webflow_sync? in sync_job
Browse files Browse the repository at this point in the history
  • Loading branch information
aedificator-nl authored and vfonic committed Jun 5, 2024
1 parent 94a75da commit 3573ab2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/jobs/webflow_sync/initial_sync_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class InitialSyncJob < ApplicationJob
def perform(collection_slug)
model_class = collection_slug.underscore.classify.constantize
model_class.where(webflow_item_id: nil).find_each do |record|
next if record.webflow_site_id.blank?
next if record.should_skip_webflow_sync?

client(record.webflow_site_id).create_item(collection_id: record.webflow_collection_id, record:)
end
Expand Down
10 changes: 10 additions & 0 deletions spec/jobs/webflow_sync/initial_sync_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
end

before(:each) do
@skip_webflow_sync = WebflowSync.configuration.skip_webflow_sync
WebflowSync.configuration.skip_webflow_sync = false

allow(Webflow::Client).to receive(:new).and_return(webflow_mock_client)
end

after(:each) do
WebflowSync.configuration.skip_webflow_sync = @skip_webflow_sync # rubocop:disable RSpec/InstanceVariable
end

it 'assigns webflow_item_id to record' do
article = create(:article)

Expand All @@ -25,7 +32,10 @@
end

it 'raises an error when it cannot find a webflow collection' do
WebflowSync.configuration.skip_webflow_sync = true
create(:article)
WebflowSync.configuration.skip_webflow_sync = false

error_message = "Cannot find collection articles for Webflow site #{ENV.fetch('WEBFLOW_SITE_ID')}"

expect do
Expand Down

0 comments on commit 3573ab2

Please sign in to comment.