diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-17 06:09:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-17 06:09:27 +0300 |
commit | 9345f69894862e02f3491ea3136c3ed2b23fd5b8 (patch) | |
tree | 08a4a1b2861cd5894e2a1146300a206071f06ea3 /spec/lib/gitlab/database_importers | |
parent | d43aaf286fe6b8e8383e73ea580274d8841608d7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/database_importers')
-rw-r--r-- | spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb b/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb index 0b8f64e97a1..923f620a81d 100644 --- a/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb +++ b/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb @@ -50,7 +50,7 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do end end - context 'with application settings and admin users' do + context 'with application settings and admin users', :request_store do let(:project) { result[:project] } let(:group) { result[:group] } let(:application_setting) { Gitlab::CurrentSettings.current_application_settings } @@ -58,8 +58,9 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do let!(:user) { create(:user, :admin) } before do - allow(ApplicationSetting).to receive(:current_without_cache) { application_setting } - application_setting.allow_local_requests_from_web_hooks_and_services = true + stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') + + application_setting.update(allow_local_requests_from_web_hooks_and_services: true) end shared_examples 'has prometheus service' do |listen_address| @@ -130,12 +131,17 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do it 'saves the project id' do expect(result[:status]).to eq(:success) - expect(application_setting.self_monitoring_project_id).to eq(project.id) + expect(application_setting.reload.self_monitoring_project_id).to eq(project.id) end - it 'expires application_setting cache' do - expect(Gitlab::CurrentSettings).to receive(:expire_current_application_settings) + it 'creates a Prometheus service' do expect(result[:status]).to eq(:success) + + services = result[:project].reload.services + + expect(services.count).to eq(1) + # Ensures PrometheusService#self_monitoring_project? is true + expect(services.first.allow_local_api_url?).to be_truthy end it 'creates an environment for the project' do @@ -158,8 +164,8 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do end it 'returns error when saving project ID fails' do - allow(application_setting).to receive(:update).and_call_original - allow(application_setting).to receive(:update) + allow(subject.application_settings).to receive(:update).and_call_original + allow(subject.application_settings).to receive(:update) .with(self_monitoring_project_id: anything) .and_return(false) @@ -175,8 +181,8 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do let(:existing_project) { create(:project, namespace: existing_group) } before do - application_setting.instance_administrators_group_id = existing_group.id - application_setting.self_monitoring_project_id = existing_project.id + application_setting.update(instance_administrators_group_id: existing_group.id, + self_monitoring_project_id: existing_project.id) end it 'returns success' do @@ -189,7 +195,7 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do context 'when local requests from hooks and services are not allowed' do before do - application_setting.allow_local_requests_from_web_hooks_and_services = false + application_setting.update(allow_local_requests_from_web_hooks_and_services: false) end it_behaves_like 'has prometheus service', 'http://localhost:9090' |