Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix frozen string in validatable module #5563

Merged
merged 1 commit into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### Unreleased

* bug fixes
* Fix frozen string exception in validatable. [#5563](https://github.com/heartcombo/devise/pull/5563) [#5465](https://github.com/heartcombo/devise/pull/5465) [@mameier](https://github.com/mameier)

### 4.9.0 - 2023-02-17

Expand Down
2 changes: 1 addition & 1 deletion lib/devise/models/validatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def self.assert_validations_api!(base) #:nodoc:
unavailable_validations = VALIDATIONS.select { |v| !base.respond_to?(v) }

unless unavailable_validations.empty?
raise "Could not use :validatable module since #{base} does not respond " <<
raise "Could not use :validatable module since #{base} does not respond " \
"to the following methods: #{unavailable_validations.to_sentence}."
end
end
Expand Down
5 changes: 4 additions & 1 deletion test/models/validatable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,12 @@ class ValidatableTest < ActiveSupport::TestCase
end

test 'should not be included in objects with invalid API' do
assert_raise RuntimeError do
exception = assert_raise RuntimeError do
Class.new.send :include, Devise::Models::Validatable
end

expected_message = /Could not use :validatable module since .* does not respond to the following methods: validates_presence_of.*/
assert_match expected_message, exception.message
end

test 'required_fields should be an empty array' do
Expand Down