From cb5b5cb5f79bb2187d8124df91af4c8e1bfd7256 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 2 May 2018 18:58:48 +0200 Subject: Slightly reduce RAM usage (#7301) * No need to re-require sidekiq plugins, they are required via Gemfile * Add derailed_benchmarks tool, no need to require TTY gems in Gemfile * Replace ruby-oembed with FetchOEmbedService Reduce startup by 45382 allocated objects * Remove preloaded JSON-LD in favour of caching HTTP responses Reduce boot RAM by about 6 MiB * Fix tests * Fix test suite by stubbing out JSON-LD contexts --- spec/rails_helper.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'spec/rails_helper.rb') diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index dc1f32e085c..c575128e408 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -50,6 +50,14 @@ RSpec.configure do |config| Capybara.app_host = "http#{https ? 's' : ''}://#{ENV.fetch('LOCAL_DOMAIN')}" end + config.before :each, type: :controller do + stub_jsonld_contexts! + end + + config.before :each, type: :service do + stub_jsonld_contexts! + end + config.after :each do Rails.cache.clear @@ -69,3 +77,9 @@ end def attachment_fixture(name) File.open(File.join(Rails.root, 'spec', 'fixtures', 'files', name)) end + +def stub_jsonld_contexts! + stub_request(:get, 'https://www.w3.org/ns/activitystreams').to_return(request_fixture('json-ld.activitystreams.txt')) + stub_request(:get, 'https://w3id.org/identity/v1').to_return(request_fixture('json-ld.identity.txt')) + stub_request(:get, 'https://w3id.org/security/v1').to_return(request_fixture('json-ld.security.txt')) +end -- cgit v1.2.3