Commit baffe82a authored by Bob Van Landuyt's avatar Bob Van Landuyt

Hide instance statistics on new installations

Making the migrations and the default do the right thing in the first
place. This makes 20180806094307 a no-op.
parent 0f871450
...@@ -297,7 +297,7 @@ class ApplicationSetting < ActiveRecord::Base ...@@ -297,7 +297,7 @@ class ApplicationSetting < ActiveRecord::Base
unique_ips_limit_per_user: 10, unique_ips_limit_per_user: 10,
unique_ips_limit_time_window: 3600, unique_ips_limit_time_window: 3600,
usage_ping_enabled: Settings.gitlab['usage_ping_enabled'], usage_ping_enabled: Settings.gitlab['usage_ping_enabled'],
instance_statistics_visibility_private: false, instance_statistics_visibility_private: true,
user_default_external: false user_default_external: false
} }
end end
......
...@@ -10,7 +10,7 @@ class AddInstanceStatisticsVisibilityToApplicationSetting < ActiveRecord::Migrat ...@@ -10,7 +10,7 @@ class AddInstanceStatisticsVisibilityToApplicationSetting < ActiveRecord::Migrat
def up def up
add_column_with_default(:application_settings, :instance_statistics_visibility_private, add_column_with_default(:application_settings, :instance_statistics_visibility_private,
:boolean, :boolean,
default: false, default: true,
allow_null: false) allow_null: false)
end end
......
...@@ -35,6 +35,10 @@ RSpec.describe 'Dashboard Active Tab', :js do ...@@ -35,6 +35,10 @@ RSpec.describe 'Dashboard Active Tab', :js do
context 'on instance statistics' do context 'on instance statistics' do
subject { visit instance_statistics_root_path } subject { visit instance_statistics_root_path }
before do
stub_application_setting(instance_statistics_visibility_private: false)
end
it 'shows Instance Statistics` as active' do it 'shows Instance Statistics` as active' do
subject subject
......
...@@ -183,7 +183,13 @@ describe GlobalPolicy do ...@@ -183,7 +183,13 @@ describe GlobalPolicy do
describe 'read instance statistics' do describe 'read instance statistics' do
context 'regular user' do context 'regular user' do
it { is_expected.to be_allowed(:read_instance_statistics) } context 'when instance statistics are publicly available' do
before do
stub_application_setting(instance_statistics_visibility_private: false)
end
it { is_expected.to be_allowed(:read_instance_statistics) }
end
context 'when instance statistics are set to private' do context 'when instance statistics are set to private' do
before do before do
...@@ -197,7 +203,13 @@ describe GlobalPolicy do ...@@ -197,7 +203,13 @@ describe GlobalPolicy do
context 'admin' do context 'admin' do
let(:current_user) { create(:admin) } let(:current_user) { create(:admin) }
it { is_expected.to be_allowed(:read_instance_statistics) } context 'when instance statistics are publicly available' do
before do
stub_application_setting(instance_statistics_visibility_private: false)
end
it { is_expected.to be_allowed(:read_instance_statistics) }
end
context 'when instance statistics are set to private' do context 'when instance statistics are set to private' do
before do before do
......
...@@ -25,7 +25,7 @@ describe API::Settings, 'Settings' do ...@@ -25,7 +25,7 @@ describe API::Settings, 'Settings' do
expect(json_response['ed25519_key_restriction']).to eq(0) expect(json_response['ed25519_key_restriction']).to eq(0)
expect(json_response['circuitbreaker_failure_count_threshold']).not_to be_nil expect(json_response['circuitbreaker_failure_count_threshold']).not_to be_nil
expect(json_response['performance_bar_allowed_group_id']).to be_nil expect(json_response['performance_bar_allowed_group_id']).to be_nil
expect(json_response['instance_statistics_visibility_private']).to be(false) expect(json_response['instance_statistics_visibility_private']).to be(true)
expect(json_response).not_to have_key('performance_bar_allowed_group_path') expect(json_response).not_to have_key('performance_bar_allowed_group_path')
expect(json_response).not_to have_key('performance_bar_enabled') expect(json_response).not_to have_key('performance_bar_enabled')
end end
......
...@@ -9,6 +9,8 @@ shared_examples 'instance statistics availability' do ...@@ -9,6 +9,8 @@ shared_examples 'instance statistics availability' do
describe 'GET #index' do describe 'GET #index' do
it 'is available when the feature is available publicly' do it 'is available when the feature is available publicly' do
stub_application_setting(instance_statistics_visibility_private: false)
get :index get :index
expect(response).to have_gitlab_http_status(:success) expect(response).to have_gitlab_http_status(:success)
......
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