summaryrefslogtreecommitdiffstats
path: root/test/unit/project_test.rb
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2021-10-03 19:44:39 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2021-10-03 19:44:39 +0000
commit05e9d7883b6bf6dc556196a75b6ab8e389d834e2 (patch)
tree4faf6589808c4a580a5f5d0223d6142b8e32c461 /test/unit/project_test.rb
parent65f31d52cdd612407200f6af9045fa682345fab8 (diff)
downloadredmine-05e9d7883b6bf6dc556196a75b6ab8e389d834e2.tar.gz
redmine-05e9d7883b6bf6dc556196a75b6ab8e389d834e2.zip
Use sanitize_sql_like in like scopes (#35073).
Patch Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@21231 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/project_test.rb')
-rw-r--r--test/unit/project_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb
index 7a0e9934f..5a1497809 100644
--- a/test/unit/project_test.rb
+++ b/test/unit/project_test.rb
@@ -1127,4 +1127,20 @@ class ProjectTest < ActiveSupport::TestCase
assert_equal 'valuea', project.custom_field_value(cf1)
assert_nil project.custom_field_value(cf2)
end
+
+ def test_like_scope_should_escape_query
+ project = Project.find 'ecookbook'
+ r = Project.like('eco_k')
+ assert_not_include project, r
+ r = Project.like('eco%k')
+ assert_not_include project, r
+
+ project.update_column :name, 'Eco%kbook'
+ r = Project.like('eco%k')
+ assert_include project, r
+
+ project.update_column :name, 'Eco_kbook'
+ r = Project.like('eco_k')
+ assert_include project, r
+ end
end