Memorize config options instead of reading them from file over and over again

This commit is contained in:
Sebastian Serth
2022-09-23 11:39:08 +02:00
parent c2c8cf4ae6
commit 5881795d5f
5 changed files with 11 additions and 22 deletions

View File

@ -5,12 +5,9 @@ require 'rails_helper'
describe CodeharborLinksController do
let(:user) { create(:teacher) }
let(:codeocean_config) { instance_double(CodeOcean::Config) }
let(:codeharbor_config) { {codeharbor: {enabled: true, url: 'https://test.url'}} }
before do
allow(CodeOcean::Config).to receive(:new).with(:code_ocean).and_return(codeocean_config)
allow(codeocean_config).to receive(:read).and_return(codeharbor_config)
allow(CodeharborLinkPolicy::CODEHARBOR_CONFIG).to receive(:[]).with(:enabled).and_return(true)
allow(CodeharborLinkPolicy::CODEHARBOR_CONFIG).to receive(:[]).with(:url).and_return('https://test.url')
allow(controller).to receive(:current_user).and_return(user)
end