diff options
author | Mario de la Ossa <mariodelaossa@gmail.com> | 2018-02-01 13:48:51 -0600 |
---|---|---|
committer | Mario de la Ossa <mariodelaossa@gmail.com> | 2018-02-02 10:13:52 -0600 |
commit | 47db6d5699b4b7573cef43fd0360a7b5c1df63a8 (patch) | |
tree | a6920e744923702efcf8babbc07cce849c758af2 | |
parent | ef57cde2a5f4fdece03244253663d5e4915fac21 (diff) | |
download | gitlab-ce-37698-current-settings.tar.gz |
fix Gitlab::CurrentSettings specs37698-current-settings
-rw-r--r-- | lib/gitlab/current_settings.rb | 2 | ||||
-rw-r--r-- | spec/controllers/oauth/applications_controller_spec.rb | 3 | ||||
-rw-r--r-- | spec/lib/gitlab/current_settings_spec.rb | 11 |
3 files changed, 10 insertions, 6 deletions
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb index 98eaae9f831..b7c596a973d 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb @@ -14,7 +14,7 @@ module Gitlab end def method_missing(name, *args, &block) - current_application_settings.send(name, *args, &block) # rubocop:disable Gitlab/PublicSend + current_application_settings.send(name, *args, &block) # rubocop:disable GitlabSecurity/PublicSend end def respond_to_missing?(name, include_private = false) diff --git a/spec/controllers/oauth/applications_controller_spec.rb b/spec/controllers/oauth/applications_controller_spec.rb index b38652e7ab9..1195f44f37d 100644 --- a/spec/controllers/oauth/applications_controller_spec.rb +++ b/spec/controllers/oauth/applications_controller_spec.rb @@ -16,8 +16,7 @@ describe Oauth::ApplicationsController do end it 'redirects back to profile page if OAuth applications are disabled' do - settings = double(user_oauth_applications?: false) - allow_any_instance_of(Gitlab::CurrentSettings).to receive(:current_application_settings).and_return(settings) + allow(Gitlab::CurrentSettings.current_application_settings).to receive(:user_oauth_applications?).and_return(false) get :index diff --git a/spec/lib/gitlab/current_settings_spec.rb b/spec/lib/gitlab/current_settings_spec.rb index b5f24c2dd74..4ddcbd7eb66 100644 --- a/spec/lib/gitlab/current_settings_spec.rb +++ b/spec/lib/gitlab/current_settings_spec.rb @@ -21,7 +21,11 @@ describe Gitlab::CurrentSettings do context 'with DB available' do before do - allow_any_instance_of(described_class).to receive(:connect_to_db?).and_return(true) + # For some reason, `allow(described_class).to receive(:connect_to_db?).and_return(true)` causes issues + # during the initialization phase of the test suite, so instead let's mock the internals of it + allow(ActiveRecord::Base.connection).to receive(:active?).and_return(true) + allow(ActiveRecord::Base.connection).to receive(:table_exists?).and_call_original + allow(ActiveRecord::Base.connection).to receive(:table_exists?).with('application_settings').and_return(true) end it 'attempts to use cached values first' do @@ -91,8 +95,9 @@ describe Gitlab::CurrentSettings do context 'with DB unavailable' do before do - allow_any_instance_of(described_class).to receive(:connect_to_db?).and_return(false) - allow_any_instance_of(described_class).to receive(:retrieve_settings_from_database_cache?).and_return(nil) + # For some reason, `allow(described_class).to receive(:connect_to_db?).and_return(false)` causes issues + # during the initialization phase of the test suite, so instead let's mock the internals of it + allow(ActiveRecord::Base.connection).to receive(:active?).and_return(false) end it 'returns an in-memory ApplicationSetting object' do |