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/update_minimum_password_length_spec.rb')
-rw-r--r--spec/migrations/update_minimum_password_length_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/migrations/update_minimum_password_length_spec.rb b/spec/migrations/update_minimum_password_length_spec.rb
new file mode 100644
index 00000000000..0a763e5ce0f
--- /dev/null
+++ b/spec/migrations/update_minimum_password_length_spec.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20191205084057_update_minimum_password_length')
+
+describe UpdateMinimumPasswordLength, :migration do
+ let(:application_settings) { table(:application_settings) }
+ let(:application_setting) do
+ application_settings.create!(
+ minimum_password_length: ApplicationSetting::DEFAULT_MINIMUM_PASSWORD_LENGTH
+ )
+ end
+
+ before do
+ stub_const('ApplicationSetting::DEFAULT_MINIMUM_PASSWORD_LENGTH', 10)
+ allow(Devise.password_length).to receive(:min).and_return(12)
+ end
+
+ it 'correctly migrates minimum_password_length' do
+ reversible_migration do |migration|
+ migration.before -> {
+ expect(application_setting.reload.minimum_password_length).to eq(10)
+ }
+
+ migration.after -> {
+ expect(application_setting.reload.minimum_password_length).to eq(12)
+ }
+ end
+ end
+end