Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/migrations/20221025043930_change_default_value_on_password_last_changed_at_to_user_details_spec.rb')
-rw-r--r--spec/migrations/20221025043930_change_default_value_on_password_last_changed_at_to_user_details_spec.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/migrations/20221025043930_change_default_value_on_password_last_changed_at_to_user_details_spec.rb b/spec/migrations/20221025043930_change_default_value_on_password_last_changed_at_to_user_details_spec.rb
new file mode 100644
index 00000000000..4d6f06eb146
--- /dev/null
+++ b/spec/migrations/20221025043930_change_default_value_on_password_last_changed_at_to_user_details_spec.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_migration!
+
+RSpec.describe ChangeDefaultValueOnPasswordLastChangedAtToUserDetails, :migration do
+ let(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') }
+ let(:users) { table(:users) }
+ let(:user_details) { table(:user_details) }
+
+ it 'correctly migrates up and down' do
+ user = create_user!(email: '1234@abc')
+ user_details.create!(user_id: user.id, provisioned_by_group_id: namespace.id)
+
+ expect(UserDetail.find_by(user_id: user.id).password_last_changed_at).to be_nil
+
+ migrate!
+
+ user = create_user!(email: 'abc@1234')
+ user_details.create!(user_id: user.id, provisioned_by_group_id: namespace.id)
+
+ expect(UserDetail.find_by(user_id: user.id).password_last_changed_at).not_to be_nil
+ end
+
+ private
+
+ def create_user!(name: "Example User", email: "user@example.com", user_type: nil)
+ users.create!(
+ name: name,
+ email: email,
+ username: name,
+ projects_limit: 0,
+ user_type: user_type,
+ confirmed_at: Time.current
+ )
+ end
+end