about summary refs log tree commit diff
path: root/spec/rails_helper.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-05-02 18:58:48 +0200
committerGitHub <noreply@github.com>2018-05-02 18:58:48 +0200
commitcb5b5cb5f79bb2187d8124df91af4c8e1bfd7256 (patch)
tree76f728b51beda1992b14e3bc83f6a67fdd77dce3 /spec/rails_helper.rb
parent71a7cea73fdfb45d06986e108b2ce1dbf7e32579 (diff)
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
Diffstat (limited to 'spec/rails_helper.rb')
-rw-r--r--spec/rails_helper.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index dc1f32e08..c575128e4 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