@@ -121,8 +121,6 module Redmine | |||
|
121 | 121 | case connection.adapter_name |
|
122 | 122 | when /postgresql/i |
|
123 | 123 | "#{column} ILIKE #{value}" |
|
124 | when /mysql/i | |
|
125 | "LOWER(#{column}) COLLATE utf8_bin LIKE LOWER(#{value})" | |
|
126 | 124 | else |
|
127 | 125 | "#{column} LIKE #{value}" |
|
128 | 126 | end |
@@ -167,6 +167,10 class ActiveSupport::TestCase | |||
|
167 | 167 | ActiveRecord::Base.connection.adapter_name =~ /sqlite/i |
|
168 | 168 | end |
|
169 | 169 | |
|
170 | def mysql? | |
|
171 | ActiveRecord::Base.connection.adapter_name =~ /mysql/i | |
|
172 | end | |
|
173 | ||
|
170 | 174 | def assert_save(object) |
|
171 | 175 | saved = object.save |
|
172 | 176 | message = "#{object.class} could not be saved" |
@@ -149,17 +149,26 class SearchTest < ActiveSupport::TestCase | |||
|
149 | 149 | assert_include issue, r |
|
150 | 150 | end |
|
151 | 151 | |
|
152 | def test_search_should_not_use_ruby_downcase | |
|
153 | skip "SQLite does not support case insensitive match for non-ASCII characters" if sqlite? | |
|
154 | issue1 = Issue.generate!(:subject => "Special chars: ÖÖ") | |
|
155 | issue2 = Issue.generate!(:subject => "Special chars: Öö") | |
|
156 | Issue.generate!(:subject => "Special chars: oo") | |
|
157 | Issue.generate!(:subject => "Special chars: OO") | |
|
158 | ||
|
159 | r = Issue.search_results('ÖÖ') | |
|
160 | assert_include issue1, r | |
|
161 | assert_include issue2, r | |
|
162 | assert_equal 2, r.size | |
|
152 | def test_search_should_be_case_insensitive_with_accented_characters | |
|
153 | unless sqlite? | |
|
154 | issue1 = Issue.generate!(:subject => "Special chars: ÖÖ") | |
|
155 | issue2 = Issue.generate!(:subject => "Special chars: Öö") | |
|
156 | ||
|
157 | r = Issue.search_results('ÖÖ') | |
|
158 | assert_include issue1, r | |
|
159 | assert_include issue2, r | |
|
160 | end | |
|
161 | end | |
|
162 | ||
|
163 | def test_search_should_be_case_and_accent_insensitive_with_mysql | |
|
164 | if mysql? | |
|
165 | issue1 = Issue.generate!(:subject => "OO") | |
|
166 | issue2 = Issue.generate!(:subject => "oo") | |
|
167 | ||
|
168 | r = Issue.search_results('ÖÖ') | |
|
169 | assert_include issue1, r | |
|
170 | assert_include issue2, r | |
|
171 | end | |
|
163 | 172 | end |
|
164 | 173 | |
|
165 | 174 | private |
General Comments 0
You need to be logged in to leave comments.
Login now