debian-mirror-gitlab/spec/migrations/update_minimum_password_length_spec.rb

31 lines
838 B
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
require 'spec_helper'
2021-09-04 01:27:46 +05:30
require_migration!
2020-01-01 13:55:28 +05:30
2020-07-28 23:09:34 +05:30
RSpec.describe UpdateMinimumPasswordLength do
2020-01-01 13:55:28 +05:30
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)
2021-11-11 11:23:49 +05:30
allow(Devise).to receive(:password_length).and_return(12..20)
2020-01-01 13:55:28 +05:30
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