Defect #27122 » case_sensitive_filter_for_version_name_2.patch
app/models/version.rb | ||
---|---|---|
134 | 134 |
scope :like, lambda {|arg| |
135 | 135 |
if arg.present? |
136 | 136 |
pattern = "%#{arg.to_s.strip}%" |
137 |
where("LOWER(#{Version.table_name}.name) LIKE :p", :p => pattern)
|
|
137 |
where([Redmine::Database.like("#{Version.table_name}.name", '?'), pattern])
|
|
138 | 138 |
end |
139 | 139 |
} |
140 | 140 |
scope :open, lambda { where(:status => 'open') } |
test/unit/version_test.rb | ||
---|---|---|
277 | 277 |
assert_equal false, version.deletable? |
278 | 278 |
end |
279 | 279 | |
280 |
def test_like_scope_should_return_case_insensitive_version_names_partially_matched_versions |
|
281 |
version = Version.create!(:project => Project.find(1), :name => 'Test Version') |
|
282 | ||
283 |
assert_includes Version.like('Test Version'), version |
|
284 |
assert_includes Version.like('TEST VERSION'), version |
|
285 |
assert_includes Version.like('test version'), version |
|
286 |
assert_includes Version.like('test'), version |
|
287 |
assert_includes Version.like('version'), version |
|
288 |
end |
|
289 | ||
280 | 290 |
private |
281 | 291 | |
282 | 292 |
def add_issue(version, attributes={}) |