2019-12-16 07:07:43 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
2021-06-11 14:10:13 -04:00
|
|
|
require_migration!
|
2019-12-16 07:07:43 -05:00
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe UpdateMinimumPasswordLength do
|
2019-12-16 07:07:43 -05:00
|
|
|
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
|