diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-24 12:09:00 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-24 12:09:00 +0000 |
commit | ae78b85a25cb0c19c3d6a2e4e6c7ca91ed50787d (patch) | |
tree | c53ad0fcdab26725814f1dc5267f6a04ebe4cf73 /spec/migrations | |
parent | 38149afcf95e7669a7a99828c579d185b70c04dc (diff) | |
download | gitlab-ce-ae78b85a25cb0c19c3d6a2e4e6c7ca91ed50787d.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/update_application_setting_npm_package_requests_forwarding_default_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/migrations/update_application_setting_npm_package_requests_forwarding_default_spec.rb b/spec/migrations/update_application_setting_npm_package_requests_forwarding_default_spec.rb new file mode 100644 index 00000000000..dfe14b40c6e --- /dev/null +++ b/spec/migrations/update_application_setting_npm_package_requests_forwarding_default_spec.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'migrate', '20200221105436_update_application_setting_npm_package_requests_forwarding_default.rb') + +describe UpdateApplicationSettingNpmPackageRequestsForwardingDefault, :migration do + # Create test data - pipeline and CI/CD jobs. + let(:application_settings) { table(:application_settings) } + + before do + application_settings.create!(npm_package_requests_forwarding: false) + end + + # Test just the up migration. + it 'correctly migrates the application setting' do + expect { migrate! }.to change { current_application_setting }.from(false).to(true) + end + + # Test a reversible migration. + it 'correctly migrates up and down the application setting' do + reversible_migration do |migration| + # Expectations will run before the up migration, + # and then again after the down migration + migration.before -> { + expect(current_application_setting).to eq false + } + + # Expectations will run after the up migration. + migration.after -> { + expect(current_application_setting).to eq true + } + end + end + + def current_application_setting + ApplicationSetting.current_without_cache.npm_package_requests_forwarding + end +end |