diff options
author | GitLab Release Tools Bot <delivery-team+release-tools@gitlab.com> | 2021-08-31 20:25:23 +0300 |
---|---|---|
committer | GitLab Release Tools Bot <delivery-team+release-tools@gitlab.com> | 2021-08-31 20:25:23 +0300 |
commit | 3333112d46dd179a55295ebed754544a97b49b7f (patch) | |
tree | 218cc0d9d971809b17ec62c5196177025cbd075a /spec/migrations | |
parent | 2da7c8579601c14a93d4291b8cf5fa39c6eeabd8 (diff) | |
parent | 8d08c6cbe51a88fbdc5065aba6e459768e98e63b (diff) |
Merge remote-tracking branch 'dev/14-2-stable' into 14-2-stable
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/20210811122206_update_external_project_bots_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/migrations/20210811122206_update_external_project_bots_spec.rb b/spec/migrations/20210811122206_update_external_project_bots_spec.rb new file mode 100644 index 00000000000..a9c7b485cc6 --- /dev/null +++ b/spec/migrations/20210811122206_update_external_project_bots_spec.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration!('update_external_project_bots') + +RSpec.describe UpdateExternalProjectBots, :migration do + def create_user(**extra_options) + defaults = { projects_limit: 0, email: "#{extra_options[:username]}@example.com" } + + table(:users).create!(defaults.merge(extra_options)) + end + + it 'sets bot users as external if were created by external users' do + internal_user = create_user(username: 'foo') + external_user = create_user(username: 'bar', external: true) + + internal_project_bot = create_user(username: 'foo2', user_type: 6, created_by_id: internal_user.id, external: false) + external_project_bot = create_user(username: 'bar2', user_type: 6, created_by_id: external_user.id, external: false) + + migrate! + + expect(table(:users).find(internal_project_bot.id).external).to eq false + expect(table(:users).find(external_project_bot.id).external).to eq true + end +end |