Allow remote translation tests to be run offline
The method `available_locales` in `RemoteTranslations::Microsoft::AvailableLocales` needs to execute a request to an external server in order to work, meaning it will fail if the machine its executed on doesn't have an internet connection. So we're stubbing the method in the tests using it.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe RemoteTranslationsController do
|
||||
describe RemoteTranslationsController, :remote_translations do
|
||||
describe "POST create", :delay_jobs do
|
||||
let(:debate) { create(:debate) }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe RemoteTranslations::Caller do
|
||||
describe RemoteTranslations::Caller, :remote_translations do
|
||||
before do
|
||||
RemoteTranslation.skip_callback(:create, :after, :enqueue_remote_translation)
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe RemoteTranslation do
|
||||
describe RemoteTranslation, :remote_translations do
|
||||
let(:remote_translation) { build(:remote_translation, locale: :es) }
|
||||
|
||||
it "is valid" do
|
||||
|
||||
@@ -69,6 +69,11 @@ RSpec.configure do |config|
|
||||
Delayed::Worker.delay_jobs = false
|
||||
end
|
||||
|
||||
config.before(:each, :remote_translations) do
|
||||
allow(RemoteTranslations::Microsoft::AvailableLocales)
|
||||
.to receive(:available_locales).and_return(I18n.available_locales.map(&:to_s))
|
||||
end
|
||||
|
||||
config.before(:each, :with_frozen_time) do
|
||||
travel_to Time.current # TODO: use `freeze_time` after migrating to Rails 5.2.
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user