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

Merge branch '332272-reset-job-token-scope' into 'master'

Add ResetJobTokenScopeEnabledAgain migration

See merge request gitlab-org/gitlab!68079
parents d1e9426b fb876346
# frozen_string_literal: true
class ResetJobTokenScopeEnabledAgain < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
def up
with_lock_retries do
remove_column :project_ci_cd_settings, :job_token_scope_enabled
add_column :project_ci_cd_settings, :job_token_scope_enabled, :boolean, default: false, null: false
end
end
def down
# no-op
end
end
24c49a12b6624c8e215e8a0c16b1bc9acc1875e68d3727fc3904b9e2eee1d319
\ No newline at end of file
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe ResetJobTokenScopeEnabledAgain do
let(:settings) { table(:project_ci_cd_settings) }
let(:projects) { table(:projects) }
let(:namespaces) { table(:namespaces) }
let(:namespace) { namespaces.create!(name: 'gitlab', path: 'gitlab-org') }
let(:project_1) { projects.create!(name: 'proj-1', path: 'gitlab-org', namespace_id: namespace.id)}
let(:project_2) { projects.create!(name: 'proj-2', path: 'gitlab-org', namespace_id: namespace.id)}
before do
settings.create!(id: 1, project_id: project_1.id, job_token_scope_enabled: true)
settings.create!(id: 2, project_id: project_2.id, job_token_scope_enabled: false)
end
it 'migrates job_token_scope_enabled to be always false' do
expect { migrate! }
.to change { settings.where(job_token_scope_enabled: false).count }
.from(1).to(2)
end
end
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