diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-02 12:06:45 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-02 12:06:45 +0000 |
commit | bffcdf9bca11a4d43cc40e3f382f03088d36f7c6 (patch) | |
tree | c773436393b7a59b5f6b14388b9fa6402a9bd198 /spec/migrations | |
parent | 259c0cc0c4f8a49001b33d1bee577f4422e16d62 (diff) | |
download | gitlab-ce-bffcdf9bca11a4d43cc40e3f382f03088d36f7c6.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/20191125114345_add_admin_mode_protected_path_spec.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/migrations/20191125114345_add_admin_mode_protected_path_spec.rb b/spec/migrations/20191125114345_add_admin_mode_protected_path_spec.rb new file mode 100644 index 00000000000..110da221393 --- /dev/null +++ b/spec/migrations/20191125114345_add_admin_mode_protected_path_spec.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'migrate', '20191125114345_add_admin_mode_protected_path.rb') + +describe AddAdminModeProtectedPath, :migration do + ADMIN_MODE_ENDPOINT = '/admin/session' + + subject(:migration) { described_class.new } + + let(:application_settings) { table(:application_settings) } + + context 'no settings available' do + it 'makes no changes' do + expect { migrate! }.not_to change { application_settings.count } + end + end + + context 'protected_paths is null' do + before do + application_settings.create!(protected_paths: nil) + end + + it 'makes no changes' do + expect { migrate! }.not_to change { application_settings.first.protected_paths } + end + end + + it 'appends admin mode endpoint' do + application_settings.create!(protected_paths: '{a,b,c}') + + protected_paths_before = %w[a b c] + protected_paths_after = protected_paths_before.dup << ADMIN_MODE_ENDPOINT + + expect { migrate! }.to change { application_settings.first.protected_paths }.from(protected_paths_before).to(protected_paths_after) + end + + it 'new default includes admin mode endpoint' do + settings_before = application_settings.create! + + expect(settings_before.protected_paths).not_to include(ADMIN_MODE_ENDPOINT) + + migrate! + + application_settings.reset_column_information + settings_after = application_settings.create! + + expect(settings_after.protected_paths).to include(ADMIN_MODE_ENDPOINT) + end +end |