diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-08-06 12:17:52 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-08-06 12:17:52 +0000 |
commit | 77c75d2b1b4821b1f5fafd107e1925c225fb6a33 (patch) | |
tree | 092585e345f56a48fbb0a29992d9684f2b2ec121 | |
parent | 2b78eab1fa26ae734db53a13a9e2bce931d6a1ce (diff) | |
parent | baffe82ace1ca3ee247c1eee2a5c21aea2256539 (diff) | |
download | gitlab-ce-77c75d2b1b4821b1f5fafd107e1925c225fb6a33.tar.gz |
Merge branch 'bvl-instance-stats-default' into 'master'
Hide instance statistics by default
Closes #50000
See merge request gitlab-org/gitlab-ce!21044
8 files changed, 48 insertions, 7 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index bbe7811841a..04495ab2908 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -297,7 +297,7 @@ class ApplicationSetting < ActiveRecord::Base unique_ips_limit_per_user: 10, unique_ips_limit_time_window: 3600, usage_ping_enabled: Settings.gitlab['usage_ping_enabled'], - instance_statistics_visibility_private: false, + instance_statistics_visibility_private: true, user_default_external: false } end diff --git a/db/migrate/20180718005113_add_instance_statistics_visibility_to_application_setting.rb b/db/migrate/20180718005113_add_instance_statistics_visibility_to_application_setting.rb index 4b6c1f74346..f5106f07500 100644 --- a/db/migrate/20180718005113_add_instance_statistics_visibility_to_application_setting.rb +++ b/db/migrate/20180718005113_add_instance_statistics_visibility_to_application_setting.rb @@ -10,7 +10,7 @@ class AddInstanceStatisticsVisibilityToApplicationSetting < ActiveRecord::Migrat def up add_column_with_default(:application_settings, :instance_statistics_visibility_private, :boolean, - default: false, + default: true, allow_null: false) end diff --git a/db/migrate/20180806094307_change_instance_stats_visibility_default.rb b/db/migrate/20180806094307_change_instance_stats_visibility_default.rb new file mode 100644 index 00000000000..4c27cfb8cab --- /dev/null +++ b/db/migrate/20180806094307_change_instance_stats_visibility_default.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class ChangeInstanceStatsVisibilityDefault < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + change_column_default :application_settings, + :instance_statistics_visibility_private, + true + ApplicationSetting.update_all(instance_statistics_visibility_private: true) + end + + def down + change_column_default :application_settings, + :instance_statistics_visibility_private, + false + end +end diff --git a/db/schema.rb b/db/schema.rb index 2bef2971f29..924d2d81dcc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180726172057) do +ActiveRecord::Schema.define(version: 20180806094307) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -168,7 +168,7 @@ ActiveRecord::Schema.define(version: 20180726172057) do t.boolean "enforce_terms", default: false t.boolean "mirror_available", default: true, null: false t.boolean "hide_third_party_offers", default: false, null: false - t.boolean "instance_statistics_visibility_private", default: false, null: false + t.boolean "instance_statistics_visibility_private", default: true, null: false end create_table "audit_events", force: :cascade do |t| diff --git a/spec/features/dashboard/active_tab_spec.rb b/spec/features/dashboard/active_tab_spec.rb index f4d0f82d248..a7d86bd4560 100644 --- a/spec/features/dashboard/active_tab_spec.rb +++ b/spec/features/dashboard/active_tab_spec.rb @@ -35,6 +35,10 @@ RSpec.describe 'Dashboard Active Tab', :js do context 'on instance statistics' do subject { visit instance_statistics_root_path } + before do + stub_application_setting(instance_statistics_visibility_private: false) + end + it 'shows Instance Statistics` as active' do subject diff --git a/spec/policies/global_policy_spec.rb b/spec/policies/global_policy_spec.rb index 30d68e7dc9d..35f1912c1c8 100644 --- a/spec/policies/global_policy_spec.rb +++ b/spec/policies/global_policy_spec.rb @@ -183,7 +183,13 @@ describe GlobalPolicy do describe 'read instance statistics' 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 before do @@ -197,7 +203,13 @@ describe GlobalPolicy do context 'admin' do 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 before do diff --git a/spec/requests/api/settings_spec.rb b/spec/requests/api/settings_spec.rb index 3e0f47b84a1..9a662c21354 100644 --- a/spec/requests/api/settings_spec.rb +++ b/spec/requests/api/settings_spec.rb @@ -25,7 +25,7 @@ describe API::Settings, 'Settings' do expect(json_response['ed25519_key_restriction']).to eq(0) 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['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_enabled') end diff --git a/spec/support/shared_examples/instance_statistics_controllers_shared_examples.rb b/spec/support/shared_examples/instance_statistics_controllers_shared_examples.rb index 5334af841e1..9f0604b5f8e 100644 --- a/spec/support/shared_examples/instance_statistics_controllers_shared_examples.rb +++ b/spec/support/shared_examples/instance_statistics_controllers_shared_examples.rb @@ -9,6 +9,8 @@ shared_examples 'instance statistics availability' do describe 'GET #index' do it 'is available when the feature is available publicly' do + stub_application_setting(instance_statistics_visibility_private: false) + get :index expect(response).to have_gitlab_http_status(:success) |