Skip to content

Commit

Permalink
Make handling of sidekiq in testing more consistent.
Browse files Browse the repository at this point in the history
Just inline the background jobs everywhere but in the case of elasticsearch do specific things in the tests to avoid elastic being called
  • Loading branch information
mlandauer committed Aug 2, 2024
1 parent 0fb60a2 commit 335a1a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion app/services/create_or_update_application_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def self.call(authority:, council_reference:, attributes:)
application.date_scraped = attributes[:date_scraped] if attributes.key?(:date_scraped)
application.save!
create_version(application, attributes)
application.reindex
# TODO: Get rid this hack
application.reindex unless Rails.env.test?
end
application
end
Expand Down
5 changes: 5 additions & 0 deletions spec/controllers/api_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
require "spec_helper"

describe ApiController do
before do
# Disable the logging of the API call to elasticsearch
allow(LogApiCallService).to receive(:call).and_return(nil)
end

render_views

shared_examples "an authenticated API" do
Expand Down
9 changes: 2 additions & 7 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,8 @@
end

require "sidekiq/testing"
# Disable background jobs for feature specs so that emails get
# processed immediately
config.around(:each, type: :feature) do |example|
Sidekiq::Testing.inline! do
example.run
end
end
# Disable background jobs for feature specs so that emails get processed immediately
Sidekiq::Testing.inline!

config.include EmailSpec::Helpers
config.include EmailSpec::Matchers
Expand Down

0 comments on commit 335a1a3

Please sign in to comment.