Commit 8bdbf220 authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@12-10-stable-ee

parent 81bf49d9
......@@ -18,7 +18,10 @@ class ScheduleBackfillPushRulesIdInProjects < ActiveRecord::Migration[6.0]
# Update one record that is connected to the instance
value_to_be_updated_to = ScheduleBackfillPushRulesIdInProjects::PushRules.find_by(is_sample: true)&.id
execute "UPDATE application_settings SET push_rule_id = #{value_to_be_updated_to}" if value_to_be_updated_to
if value_to_be_updated_to
execute "UPDATE application_settings SET push_rule_id = #{value_to_be_updated_to}
WHERE id IN (SELECT MAX(id) FROM application_settings);"
end
ApplicationSetting.expire
......
......@@ -20,6 +20,20 @@ describe ScheduleBackfillPushRulesIdInProjects do
expect(setting.push_rule_id).to eq(sample_rule.id)
end
it 'adds global rule association to last application settings when there is more than one record without failing' do
application_settings = table(:application_settings)
setting_old = application_settings.create!
setting = application_settings.create!
sample_rule = push_rules.create!(is_sample: true)
Sidekiq::Testing.fake! do
disable_migrations_output { migrate! }
end
expect(setting_old.reload.push_rule_id).to be_nil
expect(setting.reload.push_rule_id).to eq(sample_rule.id)
end
it 'schedules worker to migrate project push rules' do
rule_1 = push_rules.create!
rule_2 = push_rules.create!
......
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