before:
Finished in 6.38 seconds after: Finished in 1.52 seconds
This commit is contained in:
parent
fd035cf777
commit
aea988a447
|
@ -21,63 +21,53 @@ describe UserSearch do
|
|||
Fabricate :post, user: user6, topic: topic
|
||||
end
|
||||
|
||||
context "all user search" do
|
||||
it "searches the user's name" do
|
||||
# this is a seriously expensive integration test, re-creating this entire test db is too expensive
|
||||
# reuse
|
||||
it "operates correctly" do
|
||||
# normal search
|
||||
results = UserSearch.search user1.name.split(" ").first
|
||||
results.size.should == 1
|
||||
results.first.should == user1
|
||||
end
|
||||
|
||||
it "searches the user's name case insensitive" do
|
||||
# lower case
|
||||
results = UserSearch.search user1.name.split(" ").first.downcase
|
||||
results.size.should == 1
|
||||
results.first.should == user1
|
||||
end
|
||||
|
||||
it "searches the user's username" do
|
||||
# username
|
||||
results = UserSearch.search user4.username
|
||||
results.size.should == 1
|
||||
results.first.should == user4
|
||||
end
|
||||
|
||||
it "searches the user's username case insensitive" do
|
||||
# case insensitive
|
||||
results = UserSearch.search user4.username.upcase
|
||||
results.size.should == 1
|
||||
results.first.should == user4
|
||||
end
|
||||
|
||||
it "searches the user's username substring" do
|
||||
# substrings
|
||||
results = UserSearch.search "mr"
|
||||
results.size.should == 6
|
||||
|
||||
results = UserSearch.search "mrb"
|
||||
results.size.should == 3
|
||||
end
|
||||
|
||||
it "searches the user's username substring upper case" do
|
||||
|
||||
results = UserSearch.search "MR"
|
||||
results.size.should == 6
|
||||
|
||||
results = UserSearch.search "MRB"
|
||||
results.size.should == 3
|
||||
end
|
||||
end
|
||||
|
||||
context "sort order respects users with posts on the topic" do
|
||||
it "Mr. Blond is first when searching his topic" do
|
||||
# topic priority
|
||||
results = UserSearch.search "mrb", topic.id
|
||||
results.first.should == user1
|
||||
end
|
||||
|
||||
it "Mr. Blue is first when searching his topic" do
|
||||
|
||||
results = UserSearch.search "mrb", topic2.id
|
||||
results.first.should == user2
|
||||
end
|
||||
|
||||
it "Mr. Brown is first when searching his topic" do
|
||||
results = UserSearch.search "mrb", topic3.id
|
||||
results.first.should == user5
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue