Fix password change
This commit is contained in:
@@ -26,5 +26,4 @@ class User < ApplicationRecord
|
|||||||
validates :username, presence: true, uniqueness: true
|
validates :username, presence: true, uniqueness: true
|
||||||
validates :email_address, presence: true, uniqueness: true
|
validates :email_address, presence: true, uniqueness: true
|
||||||
validates :lang, inclusion: { in: Languages::AVAILABLE_LANGUAGES.map { |lang| lang[:id] } }
|
validates :lang, inclusion: { in: Languages::AVAILABLE_LANGUAGES.map { |lang| lang[:id] } }
|
||||||
validates :password, presence: true, if: -> { password_change_attempt }
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -69,16 +69,6 @@ RSpec.feature "Users", type: :feature do
|
|||||||
.to change(user, :password_digest)
|
.to change(user, :password_digest)
|
||||||
.and change { user.authenticate("new_password") }.from(false).to(user)
|
.and change { user.authenticate("new_password") }.from(false).to(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should prevent changing to a blank password" do
|
|
||||||
visit edit_user_path(user)
|
|
||||||
|
|
||||||
fill_in I18n.t("activerecord.attributes.user.password"), with: ""
|
|
||||||
|
|
||||||
expect { click_button(I18n.t("helpers.buttons.save_password")); user.reload }.not_to change(user, :password)
|
|
||||||
|
|
||||||
expect(page).to have_content(I18n.t("activerecord.errors.models.user.attributes.password.blank"))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user