Commit 84611821 authored by Justin Ho's avatar Justin Ho

Update controller and fix specs

- Only fetch integrations when feature flag is
enabled.
- Even when the feature flag is on, we should still
allow updates via form to allow backwards
compatibility.
- Update spec to point to new section path under
Settings > General instead of Settings > Integrations
parent 7dca3fd1
...@@ -28,10 +28,12 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController ...@@ -28,10 +28,12 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end end
def integrations def integrations
perform_update if submitted? if Feature.enabled?(:instance_level_integrations)
# TODO: Update this with actual integrations # TODO: Update this with actual integrations
@integrations = Project.first.find_or_initialize_services.sort_by(&:title) @integrations = Project.first&.find_or_initialize_services&.sort_by(&:title)
end
perform_update if submitted?
end end
def update def update
......
...@@ -57,7 +57,7 @@ describe 'Admin updates EE-only settings' do ...@@ -57,7 +57,7 @@ describe 'Admin updates EE-only settings' do
context 'Elasticsearch settings' do context 'Elasticsearch settings' do
before do before do
visit integrations_admin_application_settings_path visit general_admin_application_settings_path
page.within('.as-elasticsearch') do page.within('.as-elasticsearch') do
click_button 'Expand' click_button 'Expand'
end end
...@@ -137,7 +137,7 @@ describe 'Admin updates EE-only settings' do ...@@ -137,7 +137,7 @@ describe 'Admin updates EE-only settings' do
namespace = create(:elasticsearch_indexed_namespace).namespace namespace = create(:elasticsearch_indexed_namespace).namespace
project = create(:elasticsearch_indexed_project).project project = create(:elasticsearch_indexed_project).project
visit integrations_admin_application_settings_path visit general_admin_application_settings_path
expect(ElasticsearchIndexedNamespace.count).to be > 0 expect(ElasticsearchIndexedNamespace.count).to be > 0
expect(ElasticsearchIndexedProject.count).to be > 0 expect(ElasticsearchIndexedProject.count).to be > 0
...@@ -166,9 +166,8 @@ describe 'Admin updates EE-only settings' do ...@@ -166,9 +166,8 @@ describe 'Admin updates EE-only settings' do
end end
it 'Enable Slack application' do it 'Enable Slack application' do
visit integrations_admin_application_settings_path
allow(Gitlab).to receive(:com?).and_return(true) allow(Gitlab).to receive(:com?).and_return(true)
visit integrations_admin_application_settings_path visit general_admin_application_settings_path
page.within('.as-slack') do page.within('.as-slack') do
check 'Enable Slack application' check 'Enable Slack application'
......
...@@ -3,5 +3,6 @@ ...@@ -3,5 +3,6 @@
FactoryBot.define do FactoryBot.define do
factory :application_setting do factory :application_setting do
default_projects_limit { 42 } default_projects_limit { 42 }
import_sources { [] }
end end
end end
...@@ -194,12 +194,6 @@ describe 'Admin updates settings', :clean_gitlab_redis_shared_state, :do_not_moc ...@@ -194,12 +194,6 @@ describe 'Admin updates settings', :clean_gitlab_redis_shared_state, :do_not_moc
expect(page).to have_content "Application settings saved successfully" expect(page).to have_content "Application settings saved successfully"
expect(current_settings.terminal_max_session_time).to eq(15) expect(current_settings.terminal_max_session_time).to eq(15)
end end
end
context 'Integrations page' do
before do
visit integrations_admin_application_settings_path
end
it 'Enable hiding third party offers' do it 'Enable hiding third party offers' do
page.within('.as-third-party-offers') do page.within('.as-third-party-offers') do
......
...@@ -208,7 +208,7 @@ describe 'Gcp Cluster', :js, :do_not_mock_admin_mode do ...@@ -208,7 +208,7 @@ describe 'Gcp Cluster', :js, :do_not_mock_admin_mode do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin) gitlab_enable_admin_mode_sign_in(admin)
visit integrations_admin_application_settings_path visit general_admin_application_settings_path
end end
it 'user does not see the offer' do it 'user does not see the offer' do
......
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
require 'spec_helper' require 'spec_helper'
describe 'admin/application_settings/integrations.html.haml' do describe 'admin/application_settings/general.html.haml' do
let(:app_settings) { build(:application_setting) } let(:app_settings) { build(:application_setting) }
let(:user) { create(:admin) }
describe 'sourcegraph integration' do describe 'sourcegraph integration' do
let(:sourcegraph_flag) { true } let(:sourcegraph_flag) { true }
...@@ -11,6 +12,7 @@ describe 'admin/application_settings/integrations.html.haml' do ...@@ -11,6 +12,7 @@ describe 'admin/application_settings/integrations.html.haml' do
before do before do
assign(:application_setting, app_settings) assign(:application_setting, app_settings)
allow(Gitlab::Sourcegraph).to receive(:feature_available?).and_return(sourcegraph_flag) allow(Gitlab::Sourcegraph).to receive(:feature_available?).and_return(sourcegraph_flag)
allow(view).to receive(:current_user).and_return(user)
end end
context 'when sourcegraph feature is enabled' do context 'when sourcegraph feature is enabled' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment