diff --git a/lib/devise/param_filter.rb b/lib/devise/param_filter.rb index 945ce26f..5d053492 100644 --- a/lib/devise/param_filter.rb +++ b/lib/devise/param_filter.rb @@ -35,7 +35,7 @@ module Devise # Determine which values should be transformed to string or passed as-is to the query builder underneath def param_requires_string_conversion?(value) - true unless value.is_a?(TrueClass) || value.is_a?(FalseClass) || value.is_a?(Fixnum) + [Fixnum, TrueClass, FalseClass, Regexp].none? {|clz| value.is_a? clz } end end end diff --git a/test/models/database_authenticatable_test.rb b/test/models/database_authenticatable_test.rb index c34e58dd..36a6f9a1 100644 --- a/test/models/database_authenticatable_test.rb +++ b/test/models/database_authenticatable_test.rb @@ -28,6 +28,12 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase assert_equal( { 'login' => 'foo@bar.com', "bool1" => true, "bool2" => false, "fixnum" => 123, "will_be_converted" => "1..10" }, conditions) end + test "param filter should not convert regular expressions to strings" do + conditions = { "regexp" => /expression/ } + conditions = Devise::ParamFilter.new([], []).filter(conditions) + assert_equal( { "regexp" => /expression/ }, conditions) + end + test 'should respond to password and password confirmation' do user = new_user assert user.respond_to?(:password)