Skip to content

Commit e41b653

Browse files
committed
Remove expectation of term case
1 parent 5b01ac9 commit e41b653

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

app/controllers/users_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def activate_account
288288
end
289289

290290
def search_users
291-
term = (params[:term] || "").strip.downcase
291+
term = params[:term].to_s.strip
292292
topic_id = params[:topic_id]
293293
topic_id = topic_id.to_i if topic_id
294294

app/models/user_search.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def self.sql term, topic_id
1414
end
1515

1616
if term.length > 0
17-
sql << "where username_lower like :term_like or
17+
sql << "where username ilike :term_like or
1818
to_tsvector('simple', name) @@
1919
to_tsquery('simple',
2020
regexp_replace(

spec/controllers/users_controller/search_users_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@
5959
json = JSON.parse(response.body)
6060
json["users"].size.should == 3
6161
end
62+
63+
it "searches the user's username substring upper case" do
64+
xhr :post, :search_users, term: "MR"
65+
json = JSON.parse(response.body)
66+
json["users"].size.should == 6
67+
68+
xhr :post, :search_users, term: "MRB"
69+
json = JSON.parse(response.body)
70+
json["users"].size.should == 3
71+
end
6272
end
6373

6474
context "sort order respects users with posts on the topic" do

0 commit comments

Comments
 (0)